Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.


In reply to Re: regex logical equivalence? by Sol-Invictus
in thread regex logical equivalence? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-19 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found