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
  • get parent LDAP DN - regex

    regex help tutorial question learning
    3
    0 Votes
    3 Posts
    10 Views
    N
    thx but i need independent code... and better understand regex. otherwise i could just use substring function, but I want to understand why my thinking doesn't work
  • Regular Expressions RegEx - Wildcards for route patterns

    regex tutorial
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Doubt in Regular Expression

    regex tutorial question
    2
    0 Votes
    2 Posts
    8 Views
    Richard DeemingR
    Looks like a job for JSON[^], not a regex. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Why regular expression doesn't work in Java 11

    regex java php com sysadmin
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Regex Lazy Match Zero or More Times (*?)

    regex question
    3
    0 Votes
    3 Posts
    10 Views
    M
    Ah, thanks very much.
  • detect and extract phone numbers

    regex help
    2
    0 Votes
    2 Posts
    7 Views
    J
    It's a good few years since I wrote RegExps and, even when I did, I could never remember whether ^ was start and $ was end or if it was the other way round. My totally untested guess is (assuming spaces are only allowed between components and / or at the start or end) is ^\s*((\+|00)?357\s*)?9[4-79]\s*\d{6}\s*$ or allowing spaces between any numbers (and / or at the start or end) is ^\s*((\+|(0\s*){2})?3\s*5\s*7\s*)?9\s*[4-79]\s*(\d\s*){6}$ Note: I'm allowing all whitespace, to just explicitly permit spaces and exclude other white space, change all of the \s patterns to single space chars I look forward to seeing what someone who actually knows RegExps comes up with to see if I am even remotely close. Edit: I've just re-read the question - you want to extract the text, not just validate it. What I have written above just validates. A simple way to extract would be to, enclose the whole of the text between ^ and $ in parentheses to get a group. Extract the group and then just drop all spaces. e.g. in Javascript theGroupThatYouHaveFound.Replace(/\s/g, ''); . An even simpler way would be to use the validation RegExp and then remove spaces from the original string (no messing around with groups).
  • finding repetead pattern

    regex help tutorial
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • 0 Votes
    3 Posts
    11 Views
    M
    I know I know. Yes, it is a challenge!
  • 06h36m03s to 06h36.1, etc., in filename via regex?

    regex help tutorial question
    4
    0 Votes
    4 Posts
    13 Views
    R
    Personally I'm confused by what you say concerning the fabrication of "seconds" from the original set of strings returned. How do you account for the fact that sequentially, 10 (counting ten) tenths adds up to one? "Over 9 files": what the heck does that mean? In my defense I'd also like to point out that after many years of observing columns of Date Modified, Date Created, Date Accessed windows time stamps (even in MSDOS this is true), what shows is ALWAYS sortable as some "true" time. Despite two "time stamps" of the same look, underneath the msification is a millisecond disposition. Am not making any sense of this am I?
  • regex for one Capital

    tutorial regex
    6
    0 Votes
    6 Posts
    18 Views
    OriginalGriffO
    Yes, it should ... :-O Fixed. "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!
  • Regex with condition? Should be easy

    regex question
    9
    0 Votes
    9 Posts
    27 Views
    P
    Thanks. Like many things in coding, writing out your spec unambiguously is most of the battle. Translating it into a programming language or regex or whatever is comparatively routine. Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
  • Use content of a database field in RegEx

    database sales regex question announcement
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Matching a unknown range of lines

    regex help tutorial question
    2
    0 Votes
    2 Posts
    7 Views
    P
    Assuming that the regex engine you are using supports the dotall operator, you can use the following: '\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*(.*?)'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\* Alternatively, you could use '\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*[\w\W]*?'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\* Advanced TypeScript Programming Projects
  • 0 Votes
    2 Posts
    8 Views
    Richard DeemingR
    You haven't specified which "flavour" of regular expressions you're using. In .NET, the following pattern should work: ^\s*(?!.*PRACTICE|.*ARCHIVE|.*RESTORE|.*CPSYSTEM)(\w+)\b That's using a zero-width positive lookahead assertion: Regular Expression Language - Quick Reference | Microsoft Docs[^] You'd need to specify RegexOptions.IgnoreCase to make the match case-insensitive. RegexOptions Enum (System.Text.RegularExpressions) | Microsoft Docs[^] "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • regex related query

    database regex help tutorial question
    2
    0 Votes
    2 Posts
    6 Views
    L
    I'd use a text (file) editor and do a replace all. "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
  • Find and Replace starting... until

    python regex tutorial question
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • How do I make this CASE INSENSATIVE?

    question
    2
    0 Votes
    2 Posts
    7 Views
    J
    If I was using perl I would just use the 'i' modifier on the expression itself so after the '/'. But following might help depending on where the regular expression is actually running. Can you make just part of a regex case-insensitive? - Stack Overflow[^]
  • Regular expression to extract row 3

    regex help question
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • 0 Votes
    7 Posts
    20 Views
    M
    f2b should have provided standard regex expressions, so people wouldn't need to learn something else.