Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: regular expression not matching

by ghosh123 (Monk)
on Mar 13, 2013 at 06:38 UTC ( #1023119=note: print w/ replies, xml ) Need Help??


in reply to Re: regular expression not matching
in thread regular expression not matching

Ooops ... I am sorry, I just pasted the wrong code.
Actually I have been using this
It was working fine as long as there was no _ and - But now , how it is to be changed to take care of '_' and '-' ?

if(/^Users of (\w+):\s+\(Total of ([0-9]+) licenses issued;\s+Total of + ([0-9]+) (licenses|license) in use/)


Comment on Re^2: regular expression not matching
Download Code
Re^3: regular expression not matching
by Anonymous Monk on Mar 13, 2013 at 06:41 UTC

      Yes , I am not able to figure out. All I understand is (\w+) is not matching Galaxy-FP or so.
      Please help me with the solution.

        Yes , I am not able to figure out.

        Well, I was thinking about the second question , can you explain what (\w+\_\-) means?

      Well, I told you, that was wrongly pasted. I was trying with something and did not clean my code before pasting. So it was.
      Basically that means some word followd by a '_' and '-'.
      But yes, that is not going to work , it was wrong.

        Basically that means some word followd by a '_' and '-'.

        Well actually no it doesn't, see perlintro#More complex regular expressions

        item 8. matches a single character in the given set, so it matches a single word character or dash, but only one character

        if you want to match it more than once, you have to use a quantifier like item 1 or item 2 from the quantifier list; or the second Quantifiers list in perlre

        So you might write

        m{^Users of (.+?): \(Total of (.+?) licenses issued; Total of (.+?) li +cense in use\)$}im m{^Users of ([^:]*): \(Total of (.+?) licenses issued; Total of (.+?) +license in use\)$}im m{^Users of ([^:]+): \(Total of (\d+) licenses issued; Total of (\d+) +license in use\)$}im m{^Users of ([\w\_\-]+): \(Total of (\d+) licenses issued; Total of (\ +d+) license in use\)$}im m{^Users of ([\w\_\-]+): \(Total of (\d+) licenses issued; Total of (\ +d+)}im

        Modern Perl ch 6 is also an introduction to regex

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2014-08-21 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls