Copy link to clipboard
Copied
Is it only [a-ln-oq-z]?
It seems unscientific and too much of a hassle.
If you want to find just lowercase latin characters
This skips numbers
(?=[a-z])(?![mp]).
If you want to include upper and lowercase
(?i)(?=[a-z])(?![mp]).
If you want to inclue any letter from any lanaguge not just latin a-z
(?=\p{L})(?![mp]).
again add (?i) at the start if you want to inlude upper and lower case
This should only catch a-z and not numbers or any other characters
But if you want all characters a-z in all languages then use \p{L}
Copy link to clipboard
Copied
@dublove I think that is the best way. You can also do
[^mp]
but that will find every character except m and p.
So what you have is fine, and probably optimal.
- Mark
P.S. can you please double check the translation of "unscientific"—we don't use it that way. Perhaps you mean "inefficient" or "clumsy"? "Scientific" means about science, so unscientific just means not about science or, more often, about pseudo-science.
Copy link to clipboard
Copied
Yes, I'm "unscientific" in the sense of being inefficient.
But it's more focused on “not the best thinking or techniques”.
Copy link to clipboard
Copied
Yes I thought so. It would be appropriate to use "inelegant", which is often used to describe code that isn't "elegant".
Copy link to clipboard
Copied
I found a weird way that it works. But I wonder if it could be a pitfall?
[^a-z]|[^mp]
It doesn't seem right either, in fact it's just [^mp]
Copy link to clipboard
Copied
Yes that won't be much help. It finds any character that isn't lowercase a-z followed by any character that isn't m or p.
So it would match "55" or "TV" or two tab characters.
Copy link to clipboard
Copied
If you want to find just lowercase latin characters
This skips numbers
(?=[a-z])(?![mp]).
If you want to include upper and lowercase
(?i)(?=[a-z])(?![mp]).
If you want to inclue any letter from any lanaguge not just latin a-z
(?=\p{L})(?![mp]).
again add (?i) at the start if you want to inlude upper and lower case
This should only catch a-z and not numbers or any other characters
But if you want all characters a-z in all languages then use \p{L}
Copy link to clipboard
Copied
牛B
Copy link to clipboard
Copied
No idea what this reply is about
Copy link to clipboard
Copied
you're so powerful that you have no enemies.
You're so strong it's hard to believe.
Copy link to clipboard
Copied
Thank you - very nice words
Copy link to clipboard
Copied
Hi @Eugene Tyson I've learned from you. I have never seen that configuration of positive and negative lookarounds together. Very clever!
- Mark
Copy link to clipboard
Copied
Finally, I've taught you something! Marking this one in the diary!
I think it's classed as a 'lookaround'
(?=[a-z])
This is a positive lookahead it asserts that what follows the current position is a lowercase letter from a to z.
(?![mp])
This is a negative lookahead it asserts that what follows is not an m or a p.
And that's my explanation and I'm sticking to it.
Then of course you need the any character '.' to fulfill a search to match any character matching/not matching that description.
Copy link to clipboard
Copied
Also the \p{L} token I haven't seen before, and is much nicer than the POSIX nonsense., haha. I also saw there is \P{L} which is the inverse, and can see uses for that, too. Thanks again!
Copy link to clipboard
Copied
Yeh - @Peter Kahrel put me on to these recently - some work and some don't, I bookmarked this page.
https://www.regular-expressions.info/unicode.html
For example \p{P} doesn't work unless it's \p{P*} for punctuation
I've been dabbling more and more since.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now