I have this regular expression, it's able to find everything inside square brackets ignoring the ones containing comma and other square brackets inside.
However is not finished, what I'm trying to achieve now, is to find only the ones that contains at least one '=' symbol inside the square brackets, if not, I'm not interested.
Current regex:
\[([^,\[\]]+?)\]
Input examples:
Not sure if I'm in the correct direction because I'm already getting everything inside 2 characteres when some characteres are not inside.. but how to tell to do it only when a specific character is there..?
I hope someone can give me a hand, this regex is driving me crazy
Thanks
You may use
\[([^][,=]*=[^][,]*)]
See the regex demo .
Details
\\[
- a [
char ([^][,=]*=[^][,]*)
- Group 1:
[^][,=]*
- 0 or more chars other than ]
, [
, ,
and =
=
- an equal sign [^][,]*
- 0 or more chars other than ]
, [
and ,
]
- a ]
char.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.