Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(?: (?<ctrl_code> # ^[[ # ^[ | \003 ([\^][\[]{2}) | # [Ctrl Key] >>> '\e' | '^[' | '\u001B' (?<esc> [\^][\[] | [\\][e] | [\\](?:(?i)u001b(?-i)) ) | # ^ ([\^][A-Z@])|([\^]) | # [Meta Key] \M- ([\\]M-) | # [^C] ^C | \003 ([\^]C|[\\]0{2}3) ) )+
/
gmixX

Description

Attempt to parse escape codes and their various forms used in shell keyboard shortcut binds.

In its current form all forms of escapes are/will be matched in an identical group.

  • e.g.: \e, ^[, \u001B, and \U001b all assign to the same binding (^[) in zsh's bindkey command, and therefore share a capture group.
Submitted by disk0 <www.github.com/disco0> - 4 years ago