Reputation:
I encounter a problem like this. I successfully create a pattern containing a word that is built from word-character only (no number, special character). It looks like this ^[^\d\W]*[^\d\W]*[^\d\W]$
but it works for 1 word only as below:
# "abcd" match
# "ab8d" don't match (contain a number)
# "aaaaaaaaa" match
# "aaaa!aaa" don't match (contain !)
Now I want to "extend" the pattern so it will work with a whole sentence "abcd ab8d aaaaaaaa aaaaa!aaaa"
which will match "abcd"
and "aaaaaaaa"
.
Actually, I found the solution on Regex expression to capture only words without numbers or symbols, the pattern is (?<!\S)[A-Za-z]+(?!\S)
BUT I still want to do it in my own way, since it will make me remember longer than just copy-paste code from the internet.
So my question is, if possible, is there any way to "extend" my pattern ^[^\d\W]*[^\d\W]*[^\d\W]$
to make it work for the whole sentence instead of 1 word? I'm thinking about handling the " "
character between two words.
Upvotes: 0
Views: 19