Reputation: 65
I have a pattern regex for check matching string:
\b(\w+)(?:株式会社|会社)(?:\s*)(\w+)(?:ご担当者様|様)
Problem: this pattern does not matching japanese characters
Example:
CompanyA株式会社Daniz様
=> match this pattern.
but
スタッフ株式会社本社様
=> does not match this pattern
How i can change regex to match (japaneses characters, special character, and normal character a-z A-Z 0-9)?
Upvotes: 2
Views: 975
Reputation: 4329
You can use Unicode properties to match different classes of characters. For example to match any letter in any language you can use \p{gc=IsL}
instead of \w
, which matches just Latin letters (plus underscore and digits). Or you can use specific script for just Japanese characters. In your question it's not clear if you want any letter or just Latin + Japanese letters. Also, what "special characters" do you want to include?
Upvotes: 2