Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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
[marto]: puntastic
[choroba]: o'nest
[Eily]: yes we're pretty prawn to making puns around here
Eily went to the wiktionary to check that the pronunciations of prawn and prone are actually similar. Turns out prawn can be an alternative form of porn...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-06-29 12:46 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (662 votes). Check out past polls.