I’m trying to run a regular expression (Ruby) on a file containing code and custom comment tags. I want to find all text between (/*+ ... +*/), single line or multiline.
Given:
/*+
# Testing Documentation #
## Another Documentation Line ##
This is also picked up
+*/
Some code here that is ignored
/*+ # More documentation # +*/
I would want to match each group of text between the open and closing of /*+ ... +*/
I’ve tried the following reg ex which works great for the single line example. But if I enable the multiline option, it picks up everything between the first match and last match instead of matching two or more groups.
/(?<=\/\*\+)(.*)(?=\+\*\/)/
Thanks
Make the match in the middle non-greedy (
(.*?)). Here’s a permalink to Rubular:http://rubular.com/r/0SuNNJ3vy6
The expression I used was
/(\/\*\+)(.*?)(\+\*\/)/m, fine-tune as you see fit.