Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: HELP! I am in regex-hell

by LanX (Saint)
on Jul 15, 2020 at 13:15 UTC ( [id://11119354]=note: print w/replies, xml ) Need Help??


in reply to Re^2: HELP! I am in regex-hell
in thread HELP! I am in regex-hell

you can insert spaces and linebreaks to be ignored when using the /x modifier.

Long regexps like this may impress your friends, but can be hard to decipher. In complex situations like this, the /x modifier for a match is invaluable. It allows one to put nearly arbitrary whitespace and comments into a regexp without affecting their meaning. Using it, we can rewrite our "extended" regexp in the more pleasing form

/^ [+-]? # first, match an optional sign ( # then match integers or f.p. mantissas: \d+\.\d+ # mantissa of the form a.b |\d+\. # mantissa of the form a. |\.\d+ # mantissa of the form .b |\d+ # integer of the form a ) ( [eE] [+-]? \d+ )? # finally, optionally match an exponent $/x;

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (None)
    As of 2024-04-25 01:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found