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