Hi, I am trying to look for all occurrences where « for example is not preceded by a space in order to insert one.
I tried (?!\s)(«) but it finds all « regardless whether they are preceded by a space or not.
Does anybody have any clues?
I tried (?!\s)(«) but it finds all « regardless whether they are preceded by a space or not.
(?!\s)
is a negative look-ahead assertion (see documentation), and what you want is negative look-behind assertion: (?<!\s)
.
Thanks a lot Mike, also for the documentation.
I just found it: ([^\s])(«)
Likely this is what you actually need, because I guess that you need to match only cases where the quote is immediately preceded by a character, while use of (simple) negative look-behind assertion would also match cases where the quote is the first in the paragraph.
Thank you, this behavior of the look-ahead and look-behind could help me with another issue I have actually. But I’ll open another issue for that.