MJ
asked on
Regex not working as I thought
I got this regex from a previous post which worked but is not performing the way I thought it would when I test it in a tool I'm using (see attached).
abc|def|ghi
abc|def|ghi|jkl
123|456|789
123|456|789|101112
one1|two2|3three|4four|fiv e5
sampleRegexIssue.png
[^|]+
Will split string into pieces based on the pipe separator or am I wrong? I only get back-reference $0 from it when testing and should see all back-references in the tool. The string can have N number of pipe separators but I only care about $2. What is the regex that performs that.abc|def|ghi
abc|def|ghi|jkl
123|456|789
123|456|789|101112
one1|two2|3three|4four|fiv
sampleRegexIssue.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And to answer your question, yes it does do a split in a sense
ASKER
I get an error Regular Expression is invalid? Maybe this tool isn't using javascript regex?
That site you were using is good for testing reg expressions but applying them to JavaScript you need to apply the expression in the right format using the // and g etc