Welcome Guest.   Make a donation to an author on the site August 20, 2014, 11:24:02 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2014! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: regular expressions 1010  (Read 119 times)
phitsc
Honorary Member
**
Posts: 988



see users location on a map View Profile Give some DonationCredits to this forum member
« on: Today at 02:44:22 PM »

While working with regular expressions today I stumbled over regular expressions 101. Not only does it test your regular expression as you type, but it also picks it apart and explains it to you piece by piece. Amazing!
Logged

wraith808
Supporting Member
**
Posts: 6,182



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: Today at 02:48:21 PM »

There's also https://www.debuggex.com/?re=&str=

But personally, I use RegexBuddy.  It costs.  But I haven't found anything as robust.  And I'm willing to pay for my sanity when regularly confronted by regex like this...

Formatted for Generic Code with the GeSHI Syntax Highlighter [copy or print]
  1. (?imnx) #multiline mode, explicit captures only, with comments
  2. ^ #start at beginning
  3. \s* #optional whitespace
  4. (                                           #start optional group
  5. (                                       #begin OR
  6. (part|item|exhibit|note)            #match from a specific set of words
  7. |                                   # OR
  8. (?<unknown>\w+)                     #match any old word
  9. )                                       #end OR
  10. \s{1,2}                                 #limited whitespace between each one. capture certain specific ones.
  11. )?              #end optional group
  12. \(?                                         # optional open parenthesis
  13. (                                           # begin OR
  14. ([\d]{1,2}\w?)                          # 1-2 numbers with an optional letter on the end
  15. |                                       # OR
  16. ([ivx]{1,3})                            # 1-2 roman numeral letters
  17. |                                       # OR
  18. ([a-z])                                 # 1 letters
  19. )                                           # end OR
  20. \)?                                         # optional end paren
  21. \s{0,2} # optional whitespace
  22. (                                           # begin OR
  23. ([\.](?(unknown)(\s{2,})|(\s+)))        # a period followed by at least one space if no unknown header, at least two spaces if unknown header
  24. |                                       # OR
  25. ([:]\s+)                                # colon followed by at least one space
  26. |                                       # OR
  27. (\p{Pd}+)                               # some number of dashes
  28. |                                       # OR
  29. (\)\s+)                                 # close paren followed by at leaset one space
  30. )                # end OR
  31. \s*                                         #optional whitespace

At least it's commented... right?
Logged

phitsc
Honorary Member
**
Posts: 988



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: Today at 02:52:14 PM »

...
At least it's commented... right?

On the right, you mean tongue
Logged

wraith808
Supporting Member
**
Posts: 6,182



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: Today at 02:57:26 PM »

...
At least it's commented... right?

On the right, you mean tongue

amirite? tongue

Seriously though, it's pretty impressive... though it doesn't seem to recognize global flags as in the beginning of that regex I posted.  It also doesn't seem to recognize line comments.  But that's a horrendous example... and what it does match, for a web app that costs nothing?  Impressive.
« Last Edit: Today at 03:03:07 PM by wraith808 » Logged

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.055s | Server load: 0.23 ]