Regex: Match everything between characters or new line -


i trying come regex identify instances of abc=123456|123456 following snippet:

xyz=abcdef|abcdef||abc=123456|123456||cat=dog|dog||foo=bar|bar|| xyz=abcdef|abcdef||abc=123456|123456 xyz=abcdef|abcdef||abc=123456|123456|| abc=123456|123456||xyz=abcdef|abcdef|| 

the requirement here match string can have trailing double pipe or not have it.

i using this:

/abc=(.*?)+((?=\|\|)|(?=\r|\n))/ 

but seems break or condition end of match.

appreciate in advance.

preview link: http://regexr.com/3be2t

you may use end of line anchor instead of \r or \n , have remove + exists after (.*?). +, greedy match , capturing group must contain empty string.

\babc=(.*?)(?=\|\||$) 

or

\babc=(.*?)(?=\|\||\r|\n) 

demo


Comments