Monks I have a regex question I would like to ask, probably a simple answer for you gurus out there. I have an hash value returned which can be one of two strings.
Value A CDATA[Starting SITUATION1 <311446961,2559575967> for K01.K01CSYSTE5. and Value B CDATA[Starting Enterprise situation SITUATION1 <311439572,1066403668> +for K01.K01CSYSTE5.
Now, I need to match certain parts of the string and pass them off as parameters, so for example, if value A is returned, I need to match the following values from the pattern below
CDATA[Starting SITUATION1 <311446961,2559575967> for K01.K01CSYSTE5. Starting (Param 1) SITUATION1 (Param 2) K01.K01CSYSTE5 (Param 3)
So I coded the following which works for value A
if ($elementHash->{MSGTEXT} =~ /CDATA\[(\S+)\s+(\S+)\s+.+(on|for)\s+(\ +S+)\./) { $status = $1 (Which as the value "Starting") $sitname = $2 (Which as the value "SITUATION1") $type = $4 (Which as the value "K01.K01CSYSTE5") }
But I need to alter the regex pattern so I would also match param $1, $2 and $4 for value B
CDATA[Starting Enterprise situation SITUATION1 <311439572,1066403668> for K01.K01CSYSTE5.
Notice the extra bit of text "Enterprise situation" being return in value B.So what I need is a universal pattern which will match
Starting as $1 SITUATION1 as $2 K01.K01CSYSTE5 as $4
for the possibility of either VALUE A or VALUE B string being returned Hope this makes sense
In reply to RegEx pattern by MarcAllan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |