I wanna match patterns like: '''abc'''. But there are some noise like ''''''abc''' in the document. I just want the words which are preceded by exact three " ' ". I tried " [^']'''[^'] ". But it does not work. Regular expression " '{3} " will match more than three " ' ".
So can anybody help me?
You basically already gave the solution yourself. If you want to match strings which are surrounded by exactly 3
', then do this (I use Python for my examples):If you want avoid those strings that are preceded by more than 3
', then you best take a negative look-behind assertion(?<!...):If you also want to avoid strings that are succeeded by more than 3
', add a negative look-ahead assertion(?!...):Note: It depends on your programming language whether look-ahead and look-behind are supported. If so, this is the best way to accomplish what you want.