What I've managed to do
I'm new to both python and regex. With python's re.compile, in massive number of text files, I wanted to find all kinds of dashes surrounded by spaces. I used:
search.results = re.compile(r'\s[\u00ad\u2212\u002D\u058A\u05BE\u1400\u1806\u2010-\u2015\u2E17\u2E1A\u2E3A\u2E3B\u2E40\u301C\u3030\u30A0\uFE31\uFE32\uFE58\uFE63\uFF0D\u002D\u058A\u05BE\u1806\u2010\u2011\u2012\u2013\u2014\u2015\u2E3A\u2E3B\uFE58\uFE63\uFF0D\u10EAD]\s')
(Yeah, I know about the regex module on PyPI, but I'm trying to use what I know better)
It seems to have worked fine: I got all kinds of dash-like characters with spaces around them.
What I'd like to do now
Now I'm trying to do the opposite: find all the dash-like characters that are not surrounded by spaces (that is, with a space to the left, or a space to the right, or no spaces around them at all).
What I've tried
So I tried to use the same regex above and just swap the \s at the beginning, and then the \s at the end, and then both the \s-es with \S (to find all characters that are not space-characters). And now the regex suddenly seems to have gone mad and is finding all knids of words rather than dashes and their neighbouting letters, which I expected it to do. I've no idea what's going on.
What went wrong?
\p{Pd}, then, to match any hyphen not surrounded with spaces is(?<!\s)\p{Pd}|\p{Pd}(?!\s). See regex101.com/r/yEnukG/1. But there is also another way described in my YT video here, here, it would be\p{Pd}(?!(?<=\s.)\s)