Reputation: 5755
need a little help with the regexp i make... have some text where links are encoded like
[NameLink ->link]
or [NameLink->link]
The link can be without http:// or www. Tried to get it using this pattern
/\[.{1,}\-\>.{1,}\]/
but if there are 2 such encoded links in a row then it doesn't separate them and takes also the content between two links. Can someone tell me what's the problem? Thank you
Upvotes: 2
Views: 77
Reputation: 20718
Use +?
instead of {1,}
. Also, have a read on greedy vs. nongreedy.
You may want to strip spaces using \s*
around your .+?
, this allows for both [NameLink -> link]
and [NameLink ->link]
.
Upvotes: 3