Problems? Is your data what you think it is? | |
PerlMonks |
(Solved) Extracting sometimes null string from text variableby Marshall (Canon) |
on Sep 17, 2017 at 18:24 UTC ( [id://1199556]=perlquestion: print w/replies, xml ) | Need Help?? |
Marshall has asked for the wisdom of the Perl Monks concerning the following question:
I am parsing a $text variable from which I want to extract a Club name. I have a solution that "works" as shown below. I have been unable to do this in a single regex which handles both of my cases. So I just used 3 statements. This is a pragmatic "do what works" situation and is fine as far as that goes. However, in the search for elegance, I suspect that a single regex could be constructed that handles both cases? In case2, there is a new line right after Club:. My attempts at a single regex often wind up capturing Comments: instead of a null string for Club name. Ideas welcome. Update: LanX and Anonymous Monk came up with the ball! I hadn't seen \h before, but it works here!
Back to
Seekers of Perl Wisdom
|
|