I am looking for a regex, that extracts everything after a given text (here, "HIT") until the next pipe symbol "|" which is NOT surrounded by "[[" and "]]".
Example-Text:
text | HIT = [[t1|t2]] moretext [[more braces]] | moretext | moretext
This is the regex I've tried:
HIT[ \t]*=(.[^\|]+)
Of course, this only returns "HIT = [[t1" but I am looking for a regex that returns "HIT = [[t开发者_如何学C1|t2]] moretext [[more braces]]".
Thanks for your kind support
Christian
Try this regular expression:
HIT[ \t]*=((?:[^[|]|\[\[[^[\]]*]])*)
The (?:[^[|]|\[\[[^[\]]*]])* part matches
- any sequence of either any character except
[and|([^[|]), or - a sequence of any character except
[and]that is surrounded by[[…]](\[\[[^[\]]*]]).
加载中,请稍侯......
精彩评论