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
  • 0 Votes
    1 Posts
    2 Views
    No one has replied
  • Parsing Session Campaign Data in Data Studio

    regex json question
    2
    0 Votes
    2 Posts
    7 Views
    M
    I found a solution that worked: REGEXP_EXTRACT(Session campaign, "^([^_]+)")
  • Need a bit of help concerning RegEx

    tutorial regex help question
    2
    0 Votes
    2 Posts
    8 Views
    OriginalGriffO
    The reason they are left behind is because your Regex only includes filenames that contain the text ".vpx" - which your .png files don't, so can't be matched or removed. Do two things: 1) Get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions. 2) Learn how regexes work: Regular Expression Tutorial - Learn How to Use Regular Expressions[^] I'm not going to suggest a regex at all - I have no idea what else is in the folder(s) or how you collected them and no way to find that out - a "random" regex" would be likely to delete a lot more than you actually wanted with no way to test it before you used it! "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
  • Why does this work but this doesn't

    regex help question
    5
    0 Votes
    5 Posts
    16 Views
    J
    Andrew St. Hilaire wrote: I'm trying to skip over the single character direction indicator and match "Street" whether the single character is there or not, So match the following so it returns 'Main' in the match for any of the following 1. 123 Main 2. 123 Main View 3. 123 Main N 4. 123 Main View S (\b[A-Za-z]+)((\s+[A-Za-z])?)$ First clause matches the street. Second clause optionally matches a single last character. Why the extra parens in the second clause? Because I prefer to always have a match for optionals. So in this case first match is street name and second match (always there) is either something like 'S' or it is empty/null. If the parens were not there then there might or might not be a second match (you would need to test for it.)
  • How to remove an & in the following expressions

    c++ help tutorial
    8
    0 Votes
    8 Posts
    25 Views
    V
    Thank you both Richard and k5054! The hint to look at "capture groups" was very useful! I've just tested: so find (.*MyMethod\(.*, )&(SomeClass\(.*) and replace with $1$2 gives me what I need: the ampersand has been removed! :)
  • 0 Votes
    2 Posts
    8 Views
    J
    You cannot do what you are asking with a regular expression. (There is in fact a very wrong way to attempt this which is ridiculous and would lead to nothing but a maintenance nightmare.) However in a programming language that uses regexes the algorithm that you would create would look like the following 1. Read a line 2. Parse the line to remove the timestamp. 3. Does it match the previous one? (Do whatever you want) 4. Otherwise save it for the next time 5. Go back to step 1 until there are no more lines to read.
  • Removing + - chars if lines are starting with them only

    2
    0 Votes
    2 Posts
    7 Views
    J
    The regex to match a single character at the start of the line using regex for the major languages. ^[-+] To match more than one. ^[-+]+ Replacing it is a different problem and it specifically depends on the programming language you are using and which you did not specify.
  • Find the 4th last object in this campaign

    regex help question
    3
    0 Votes
    3 Posts
    10 Views
    M
    Oh yes that has helped, thank you very much!
  • Splitting with optionally second line

    regex help question
    3
    0 Votes
    3 Posts
    11 Views
    G
    Thank you, that worked for me!
  • 0 Votes
    1 Posts
    4 Views
    No one has replied
  • 0 Votes
    2 Posts
    8 Views
    L
    I think you want to do some "string exclusions" (e.g. "12345678", "00000000", ... "99999999"); ending with an inclusion (0-9). [https://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string\](https://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string) "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
  • remove parenthese from function like string

    c++ hardware beta-testing help
    7
    0 Votes
    7 Posts
    22 Views
    M
    Hi moxol, thank you for your idea using two steps! I used this: Find: __X\("([^"]*)"(.*) Replace: "$1"q!@tr@$2 repeated n-times until no other replacement was made Then simply remove all q!@tr@) strings without regexp to remove the original closing parenthese, where q!@tr@ is any improbable string used as an identifier
  • Last occurence of a word

    php regex tutorial question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Regex to find out length

    question regex
    3
    0 Votes
    3 Posts
    11 Views
    G
    You could use a zero-length lookahead. "1234345242342356789".replaceAll(/\d(?=\d{4})/g, "*")
  • Non Zero Number

    regex help
    3
    0 Votes
    3 Posts
    10 Views
    C
    unfortunately this code is accepting 00, -0, 0.0, I agree. I will look into handling it in JS. Thanks for trying. Appreciate it.
  • Regex before match

    regex help question
    5
    0 Votes
    5 Posts
    13 Views
    M
    Yes, I think \w*bad boys\w* will do it. It's MySQL Regex expression, and it seems that it works for both Latin and non-Latin characters.
  • 0 Votes
    3 Posts
    10 Views
    R
    Sometimes things at CP are kinda hinky. Then SO usually leaves less stones unturned: .net - In Regex, what is the difference between (?!^)\G and \G(?!^)? - Stack Overflow[^] Stones unturned
  • Isn't ?= needless?

    question linux algorithms regex tutorial
    4
    0 Votes
    4 Posts
    13 Views
    D
    If you want to experiment with your expression, Google for "Expresso 3". It's free and an indispensable tool for understanding regular expressions. Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
  • 0 Votes
    7 Posts
    22 Views
    L
    Why do you need a regex for such a simple test? if (text.substring(0, 3).equals("600")) // is all you need ...
  • Adresse erfassen mittels RegEx

    question regex
    6
    0 Votes
    6 Posts
    17 Views
    M
    You may right, but im using it for a rpa tool, that accept only a regex confirm formula for extracting operations.