Skip to content

Regular Expressions

Regular Expressions discussions

This category can be followed from the open social web via the handle regular-expressions@forum.codeproject.com

188 Topics 829 Posts
  • regex pattern in order to get a list of numbers from a string

    regex
    3
    0 Votes
    3 Posts
    9 Views
    A
    You don't say what environment you are working in, so it's hard to give you useful code. However, you can probably get what you want by either doing a search & replace operation, possibly repeated, or by using some kind of "regex iterator" approach. For C++, it would be a regex iterator (iterate over all the matches of THIS pattern in THAT string). For something like Python it would be find all occurrences of THIS pattern in THAT string. In order to drop the "8;" from your example sentence, you'd want to provide a better pattern than just "some digits." Instead, use something like /(\d+):/ to match on one-or-more digits followed by a colon. You want to capture the digits, not the colon. If you can just iterate over all matches in the string, that will probably be enough. If you're doing sed or some other editor, you'll have to search and replace the line. If possible, see if you can do something like a non-greedy match (.*?) to match all the text between matches, and then replace it with a comma. (FYI: The ? operator is a non-greedy modifier in Perl-style regex engines. Other regex engines may not support this at all, or they may have a different syntax-- for example, Vim would use .\{-} for that.
  • String Replacement in 'HTML 5 FireFox'

    html regex help
    15
    0 Votes
    15 Posts
    30 Views
    D
    Never heard of DataCleaner. Don't use it and not going to start. If it's some tool you found somewhere, your best source of support is going to be whoever wrote it. Your BIGGEST mistake was never telling anyone you were using some tool to do this work instead of writing your own code to do it. Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
  • Case Conversion Regular Expression in JAVA 8

    regex tutorial java perl question
    4
    0 Votes
    4 Posts
    14 Views
    U
    Thanks man
  • Regular Expression to Change Uppercase Text to Lowercase

    regex tutorial
    13
    0 Votes
    13 Posts
    36 Views
    U
    So, this is my attempt I tried the following regex in Java 8, (?i)(Helló) (Wórld) which matches HeLlÓ WóRlD the replacement string \U$1 \L$2 should become HELLÓ wórld, but it doesn't work. Can someone please help me???
  • How to namn this?

    tutorial question
    2
    0 Votes
    2 Posts
    8 Views
    P
    Adding the leading zeroes with only a Regular Expression replacement may prove difficult. If you're trying to match the two formats, it may be better to convert the other way. What are you really trying to do?
  • Capture values using regex

    regex iot help question learning
    4
    0 Votes
    4 Posts
    10 Views
    Richard DeemingR
    Check the raw source of the string you're trying to match. It could be that the ° character is actually °, °, or °. Or it could be a different Unicode character entirely - for example: º = º / º / º ˚ = ˚ / ˚ / ˚ ᵒ = ᵒ / ᵒ ゜ = ゜ / ゜ ᣞ = ᣞ / ᣞ ⁰ = ⁰ / ⁰ Your minimum temperature regex doesn't try to match the character, but your maximum temp regex does. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • 0 Votes
    4 Posts
    10 Views
    G
    Does it have to be regex? There's StringUtils.leftPad () if you want to pad with leading 0s, as long as you know the total length you want. Or use a format string to do it. String paddedStr = String.format("%09d", originalVal); (I think) We won't sit down. We won't shut up. We won't go quietly away. YouTube, and My Mu[sic], Films and Windows Programs, etc. and FB
  • RegEx: Get Values from HTML Attribute Tags

    csharp html regex help question
    6
    0 Votes
    6 Posts
    12 Views
    D
    He was saying instead of using WebHarvery, use AngleSharp instead. Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
  • RegEx: Get Values from HTML Attribute Tags

    csharp html regex help question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • String Replacement

    csharp visual-studio beta-testing tutorial question
    6
    0 Votes
    6 Posts
    17 Views
    L
    I am not a regex expert I am afraid. But You can go to RegExr: Learn, Build, & Test RegEx[^], and try different sets to see what may work.
  • RegEx Split

    com data-structures regex help tutorial
    2
    0 Votes
    2 Posts
    6 Views
    Richard DeemingR
    Your function works fine for me if you pass in the correct values. const string input = "\"\"|*\"I have delimiter |* and an escaped \\\" quote in me\"|*100|*200|*300|*\"am a string\"|*\"\""; string[] result = Split(input, "|*", @"\""", false); Split | C# Online Compiler | .NET Fiddle[^] "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • 9 million Rows in Excel

    help question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • UAE Fax Broadcast List

    java com game-dev workspace
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Finding a specific number in a string.

    question tutorial
    3
    0 Votes
    3 Posts
    10 Views
    U
    Thanks Richard. I finally ended up working out the following: (?<=Cycle)\d{4} This returns the '0001' like I want. I actually came close to working this out before posting, but failed to notice that I had a space before the \d. Duh.
  • 0 Votes
    2 Posts
    6 Views
    L
    if ( ArticleText.Contains( "Wikiproject Intelligence Agency" ) ){ // To do. } else { // To do. } It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
  • Find Sequence of alphabets in the string

    regex help question
    3
    0 Votes
    3 Posts
    8 Views
    Richard DeemingR
    This doesn't look like a suitable case for regular expressions. You'd have to build a regex pattern containing every possible sequence to test for, because regex doesn't have a construct for comparing the difference between two characters within a match. It would probably be easier to implement this using a loop. Check each five-character substring from the input to see if it's contained within a string containing the letters in sequence, remembering to account for case and accents if required. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Cannot extract end of line data

    regex csharp testing beta-testing
    2
    0 Votes
    2 Posts
    7 Views
    J
    I'm not a Reg Exp expert, but I recall that '.' matches anything EXCEPT newline so try replacing (.*$) with ((.|\n)*$). You may also need to switch on multiline matching
  • Homework Writing Services

    com
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • 0 Votes
    1 Posts
    5 Views
    No one has replied
  • TSV out of a tab-based tree-like file

    java javascript database com data-structures
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied