Copy link to clipboard
Copied
Hi!
I'm trying to to figure out how to change the location "Beginning of paragraph" to do the opposite. I need to find en-dashes that are not at the beginning of a paragraph. I've tried ^[^]-|– but its not working as I was hoping.
Rune
Hi,
\V\K(-|–)
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
I would search for word characters, could be comma or other dots, followed by space and then the dash. I do it always for corrections to the German dash (n-dash, Gedankenstrich, is not allowed at the beginning of a line.)
Copy link to clipboard
Copied
Thanks for your suggestion.
I did try to search for "any word character->any white space->en-dash|hyphen" but for some strange reason that search also included en-dashes at the beginning of paragraph. I think it is because it includes the last character of the previous paragraph??
Rune
Copy link to clipboard
Copied
Hi,
\V\K(-|–)
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
Thanks!
This worked!
Rune
Copy link to clipboard
Copied
You doubted!? …
Best,
Michel
Copy link to clipboard
Copied
Hehe - not at all:)
Can I ask you what \V and \K is searching for?
Copy link to clipboard
Copied
\K is a lookbehind, \V is not a vertical space [especially including a carriage-return].
So, the regex searches all en-dash preceded by something that is not a … carriage-return!
That means that it can't find an en-dash at the beginning of a para because the previous glyph will be …
[ I let you answer to see if you have understood! -- I know this kind of regex is really loony! ]
Best,
Michel
Copy link to clipboard
Copied
Ok, it makes totally sense. Thanks again.
Rune
Copy link to clipboard
Copied
Some could tell this other Grep code is better because clearer:
(?<!\v)(-|–)
Explanation: an en-dash that is not preceded by … a carriage-return!
… But it's not true [more greedy!]!
As you see, Grep is truly simple to play!
Have a good day!
Best,
Michel