From
your other node you should appreciate the need for readability in regex. The guy that wrote the
original regex didn't think much about readability at all.
there are a couple of things you can do as well as using \X, like:
different delimiters
in a regex with a couple of escapes like this
/\@\\\// you can change the
/../delimiters to any character you want, as long as they are paired, like this
!\@\\\/! or
#\@\\\/#
block quoting
in a regex with lots of escaped characters use
\Q...\E notation. This works in the same way that single quotes work for strings, meaning the characters are interpeted exactly as they are written -
!\Q$@.\^[{\E! is more readable than
!\$\@\.\\\^\[\{!
<lecture mode = on>
Finally as others have already pointed out, Perl's regex are very powerful and as such difficult to "just pick up", you have to read up on regex to even begin to understand how to use them - as a beginner you should probably read these first:
perlrequick Perl regular expressions quick start
perlretut Perl regular expressions tutorial
perlfaq6 Regexes
</lecture mode>
----Signature:
You spend twenty years learning the spell that makes nude virgins appear in your bedroom, and then you're so poisoned by quicksilver fumes and half-blind from reading old grimoires that you can't remember what happens next.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.