1

This /[a-z]/i.test(s) is a JS regex that checks the string s for the presence of at least one alphabetic character.

That's great for English or Simplified English but I'd like to broaden it to match "letters" from all languages. What I'm actually trying to do is detect strings with words in them. Obviously things like Chinese aren't going to match [a-z].

Is there a reliable pan-language method to do this?

The question How can I use Unicode-aware regular expressions in JavaScript? mentions the \w symbol but the accepted response totally ignores this aspect and only covers how to enable Unicode support. It does not address the question of how to detect words.

Peter Wone
  • 17,965
  • 12
  • 82
  • 134
  • Who mentioned Unicode? One of the supposed duplicates concerns a totally different language with different regex syntax, and the other is about Unicode. The JS documentation talks about UTF8, which is what I specified when I looked for an existing question. In closing this you guarantee you will get more "duplicates". I suppose I should be grateful there weren't also downvotes and insulting comments. This is why SO is my last resort. – Peter Wone Dec 26 '22 at 03:38
  • 1
    `/\p{L}/u` matches all letters in a Unicode-aware way. That’s covered by the linked Q&A. Is this not what you wanted? Then please clarify that with an [edit]. – Sebastian Simon Dec 26 '22 at 03:43
  • @SebastianSimon A good answer to THIS question would say "Enable Unicode (see https://stackoverflow.com/questions/280712) and use `\p{L}`. You could also edit the answer to the other question and add this because _then_ it would answer the whole question. If you did that then this would actually _be_ a duplicate. – Peter Wone Dec 26 '22 at 03:53
  • @PeterWone, the lack of a satisfactory answer on the other question has no bearing on whether this is a duplicate _question_. – ChrisGPT was on strike Dec 26 '22 at 10:09
  • @Chris If I accept that then acceptance of a partial answer closes the door to getting answers to the rest of the question. I already have what I need and frankly I don't care about this anymore. I'm just pointing out how asinine and counterproductive this is to the claimed goal of a quality resource. – Peter Wone Dec 27 '22 at 02:12
  • You have options. Here are two: If you really have a different question, ask it clearly with a focus on what is different from the existing one. Or, if you simply don't think the answers on the existing question are good enough, you can add a bounty to it. But "I don't like the answers on another question that asks the same thing as mine" is not a reason to reopen questions. We mark duplicates based on the question, not the answers. – ChrisGPT was on strike Dec 27 '22 at 02:22
  • "You could also edit the answer to the other question and add this"—the dupe target has _eleven_ non-deleted answers at the moment, and none of them are accepted. Which answer are you referring to when you say "the answer"? It looks to me like several answers give the answer you are looking for. "I didn't bother reading beyond whichever answer happened to be on top when I loaded the page" is also not a reason to ask a duplicate question. – ChrisGPT was on strike Dec 27 '22 at 14:02

0 Answers0