I have a regex \[\[(.+)\]\]
. I use it to capture wikilinks like hey I [[am]] so awesome
(captures am
). How could I modify this so that hey I [[am]] more [[awesome]] than you think
yields both am
and awesome
, separately? My attempts have yielded single strings like am]] more [[awesome
. A little context: I'm using this to write a Ruby IRC bot.
P.S. Wikilinks can also be multi-word, like hey I am much [[more awesome]] than you [[probably think]].
You need to make the .+
non-greedy:
\[\[(.+?)\]\]
See this reference: ruby regexen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With