Lets say I have the following string
def name1
toSomething
def name2
toSomethingElse
How could I find name1 and name2.
Using string.match(/(?:def) (.*)/) gives me:
name1
toSomething
def name2
toSomethingElse
So how can I search the string line by line?
You could try with:
/(?:def)\s+([^\s]+)/gIn the first group you will have what you need (
name1, etc).See here: http://regex101.com/r/rH0yH8
An example of how to run it: