Given this multi-line string :
``` +++ foo The bloc 1 +++ ``` +++ foo The b l o c 2 +++ +++ foo The bloc 3 +++ ``` +++ foo the bloc 4 +++ ``` I created a regex for get the content between '+++ foo' and '+++'. All works fine :
https://regex101.com/r/HpEGen/3
Now I want capture only blocs not surrounded by two triple backtricks.
In my example, only blocs 2 and 3 must be captured because they aren't surrounded by triple backtricks.
I tried to use the Negative Lookahead assertion like this :
(?!```\n)(\+\+\+)(?: *)foo\n([\s\S]*?)\n(?:)\1
https://regex101.com/r/HpEGen/4/
But I capture the 4 groups and I don't understand why...
Thanks for any help :)
https://stackoverflow.com/questions/65571583/regex-javascript-match-a-bloc-of-text-only-if-the-bloc-is-not-surround-by-a January 05, 2021 at 08:14AM
没有评论:
发表评论