Reputation: 37
I would like to parse the text
==== Example 1 ====
Some text that doesn't contain 4 equals signs
==== Example 2 ====
More text that doesn't contain 4 equals signs
==== Example 3 ====
Even more text that doesn't contain 4 equals signs
My goal is to get an array with elements "Example 1", "Example 2", and "Example 3" using RegEx in Perl. I'm a beginner in Perl and RegEx, so initially I used the greedy method which returned text I din't want. When I later used a non-greedy method, I was only able to get "Example 1." My latest attempt:
my @matches = ($text =~ /====(*?[ -~\s])====/g);
Edit: I realize how to do this; instead I want to return multiple matches instead of one.
Upvotes: 1
Views: 366
Reputation: 9644
Why not /====\s?(.*?)\s?====/g
?
Not perfect, but if your cases are pretty simple...
Upvotes: 4