Proseller
Proseller

Reputation: 101

"|" character will get ignored

I have the string [TITLE|suffix=my value|prefix=another value] and I would like to get the match of my value.

This is what I have tried:

(?<=TITLE\|suffix=).+[^|\]]

But then the match will be my value|prefix=another value].

Why is it ignoring the character | after my value?

See here: https://regexr.com/5h0h2

Upvotes: 0

Views: 45

Answers (1)

The fourth bird
The fourth bird

Reputation: 163217

You should exclude the | and ] from being part of the match using a negated character class and repeat the character class.

(?<=TITLE\|suffix=)[^|\]]+

Regex demo

Upvotes: 3

Related Questions