Skip to content

Instantly share code, notes, and snippets.

@zaydek-old
Last active August 20, 2019 07:53
Show Gist options
  • Save zaydek-old/c3d89eb7287732ca94f5fd27399943e8 to your computer and use it in GitHub Desktop.
Save zaydek-old/c3d89eb7287732ca94f5fd27399943e8 to your computer and use it in GitHub Desktop.
Unicode regex set for horizontal and vertical characters. Live example here: https://regex101.com/r/1hvmqw/1.
// Whitespace regexes based on Perl.
//
// See `perldoc perlrecharclass` for reference.
const reH = /[\u{0009}|\u{0020}|\u{00a0}|\u{1680}|\u{180e}|\u{2000}|\u{2001}|\u{2002}|\u{2003}|\u{2004}|\u{2005}|\u{2006}|\u{2007}|\u{2008}|\u{2009}|\u{200a}|\u{202f}|\u{205f}|\u{3000}]/gu
const reV = /[\u{000a}|\u{000b}|\u{000c}|\u{000d}|\u{0085}|\u{2028}|\u{2029}]/gu
const reHV = /[\u{0009}|\u{0020}|\u{00a0}|\u{1680}|\u{180e}|\u{2000}|\u{2001}|\u{2002}|\u{2003}|\u{2004}|\u{2005}|\u{2006}|\u{2007}|\u{2008}|\u{2009}|\u{200a}|\u{202f}|\u{205f}|\u{3000}|\u{000a}|\u{000b}|\u{000c}|\u{000d}|\u{0085}|\u{2028}|\u{2029}]/gu
// H: Horizontal e.g. `\h` in Perl.
// V: Vertical e.g. `\v` in Perl.
// HV: Horizontal and vertical e.g. `\h\v` in Perl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment