hsnips icon indicating copy to clipboard operation
hsnips copied to clipboard

Unicode property escape matching with RegExp flag 'u'?

Open universemaster opened this issue 1 year ago • 0 comments

It would be useful, especially when writing latex with unicode characters, to use \p{...} to match a whole unicode category.

For example, these useful unicode categories seem supported in javascript regular expressions:

  • \p{Math_Symbol}
  • \p{L} (any letter in any script - so includes the greek letters used in math)
  • \p{Symbol}
  • \p{Separator}
  • \p{Script=Greek} or \p{Script_Extensions=Greek}

To support this, I believe, a 'u' flag could optionally be added to the new RegExp here? https://github.com/draivin/hsnips/blob/78a4b6d48f0cc66e902ca95028988583cf0f92db/src/parser.ts#L14

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes

image

universemaster avatar Feb 11 '23 16:02 universemaster