Reputation: 3143
I'm trying to match a list of different items in a text. I created a regex but it matches the whole string instead of each seperate item.
This is my current regex:
\[[a-zA-Z]\](.*)\. {1}
My test text:
[step 1] test blahblah blah [A] test item 1. [B] test item 2.
The current regex matches:
[A] test item 1. [B] test item 2.
In 1 string instead of 2 matches.
Upvotes: 0
Views: 158
Reputation: 174329
I think you want to have non-greedy behaviour:
\[[a-zA-Z]\](.*?)\. {1}
Note the question mark (?
). It says that the expression coming right before it should match as little as possible to fullfil the expression. Basically, it makes it stop before the first dot and not the last one.
Upvotes: 2