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

A regular expression

by enttoobad (Novice)
on Mar 22, 2012 at 13:23 UTC ( #961008=perlquestion: print w/replies, xml ) Need Help??
enttoobad has asked for the wisdom of the Perl Monks concerning the following question:


Is anyone able to explain what this perl regex matches?


Many thanks

Replies are listed 'Best First'.
Re: A regular expression
by dorko (Parson) on Mar 22, 2012 at 13:38 UTC
    I use YAPE::Regex::Explain to explain Regular Expressions:
    use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/999[89]\$/)->explain(); __END__ The regular expression: (?-imsx:999[89]\$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- 999 '999' ---------------------------------------------------------------------- [89] any character of: '8', '9' ---------------------------------------------------------------------- \$ '$' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------



    -- Yeah, I'm a Delt.
      that's a handy tool, thanks!
Re: A regular expression
by JavaFan (Canon) on Mar 22, 2012 at 13:27 UTC
    Any string that contains either 9998$ or 9999$.
      great, thanks very much!
Re: A regular expression
by GrandFather (Sage) on Mar 22, 2012 at 20:15 UTC

    You should take a good look at least at perlretut, and probably at some of the other Perl regular expression documentation.

    True laziness is hard work
Re: A regular expression
by planetscape (Chancellor) on Mar 24, 2012 at 22:54 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://961008]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2018-08-17 01:12 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (174 votes). Check out past polls.