First: I know this question has been beaten to death.
Second: I've looked at every resource (online editors, RexEgg, regular-expressions.info etc...) I can think of over the past few years and I still cannot grasp this part of regex. It never seems to work for me no matter what RegEx I use.
Now that the house-keeping is out of the way:
I have a large amount of text that I need to extract some data from that I think Regex is well-suited for.
The text looks like this:
2017-03-31 09:41:18 EDT [12708-4] parameters: $1 = '0', $2 = 'ON', $3 = 'ON'
Fairly obviously, I want the values for $1
, $2
and $3
. This particular example has 3 variables but it's generally between 1 and 15.
I want a regex that will capture the following:
- $1
- '0'
- $2
- 'ON'
- $3
- 'ON'
This is my regex, which matches the first group:
\d{4}.+\[[\d-]*\].+?parameters:\s((\$\d+)\s?=\s?(['\d+\w+]+))
but no combination of pluses, parentheses and commas produces anything near what I want. Even if I remove the commas from the string and just jam them together I can't get it to capture.
This guy captures everything, but the groups don't make sense:
\d{4}.+\[[\d-]*\].+?parameters:\s(((\$\d+)\s?=\s?(['\d+\w+]+),?\s?)+)
Can someone end my misery here and explain to me how to capture repeated text in a regex if the text is separated by characters that I don't care about?