I'm trying to parse a document structure like this:
Headline
c=myClass1 myClass2 myClass3
Some text plus a number3gr
More text plus another number2cm
More text plus another number2.2m
I have a regular expression that is capturing the important parts into groups:
/(.*)[\r\n]c=(.*)[\r\n]*([a-zA-Z\s]*)(\d*\.?\d*)(\w*)[\r\n]/g
Later I'm using the groups to build a html-string:
'<xmp><!--begin recipe--\><h2>$1</h2><div class="$2"><div class="serves">Serves: <input type="text" class="servesinput" value="2" size="3"></div><span class="oldMulti">2</span></br><table class="ingredients"><tr><th>Amount:</th><th>Ingredient:</th></tr><tr><td class="amount $5 ">$4</td><td>$3</td></tr></div></xmp>'
This is where I am stuck: after the empty line, there can be any number of lines like these:
Some text plus a number3gr
Is there a way to re-use this part of my reg exp as many times as necessary (as many times as there are those type of rows):
([a-zA-Z\s]*)(\d*\.?\d*)(\w*)[\r\n]
Maybe I can make use of subgroups? But then I have no idea how to repeat the results inside the html-string.