4 ms·
Unicode conforming regular expression engines are supposed to support the \p or \P property syntax [1] so you should be able to match hyphen characters with \p{
by hgs3 2y ago
Unicode conforming regular expression engines are supposed to support the \p or \P property syntax [1] so you should be able to match hyphen characters with \p{Hyphen} or \p{Dash}.
[1] https://www.unicode.org/reports/tr18/#property_syntax https://www.unicode.org/reports/tr18/#property_syntax
- account42 2y agoVery nice for Unicode to provide a solution to the problem Unicode created.
- samatman 2y agoUnicode did not create the problem of many similar-looking dash-like characters with different meanings and widths. It documented it, at most.
- gknoy 2y agoThanks for linking this! I also learned that support for `\p{}` syntax isn't supported in the Python `re` library, and they recommend the api-compatible `regex` library, which does have support for that.