Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: RegEx pattern

by cdarke (Prior)
on Aug 30, 2011 at 09:00 UTC ( [id://923144]=note: print w/replies, xml ) Need Help??


in reply to RegEx pattern

Why not just make the 'Enterprise situation' text optional?
if ($elementHash->{MSGTEXT} =~ /CDATA\[(\S+)\s+(?:Enterprise situation +\s+)?(\S+)\s+.+(on|for)\s+(\S+)\./)
Notice that the group (?:Enterprise situation\s+) is a non-capturing parentheses group, which means that $1,$2,$4 are unaffected by the new group. You might also do the same with (?:on|for) which would mean that $4 becomes $3. This avoids the overhead of capturing text you don't need and, more importantly, means you can concentrate on the groups you are actually interested in.

Replies are listed 'Best First'.
Re^2: RegEx pattern
by MarcAllan (Novice) on Aug 30, 2011 at 17:27 UTC

    Exactly what I needed, thank you

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found