Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(\$) # Regexp for textmate dynamic variables #TM_( # BUNDLE_SUPPORT|COMMENT_(?:END|MODE|START)|CURRENT_(?:LINE|WORD)|DIRECTORY|FILE(?:NAME|PATH)| # LINE_(?:INDEX|NUMBER)|PROJECT_DIRECTORY|SCOPE|SELECTED_(?:FILE[S]?|TEXT)|SOFT_TABS|SUPPORT_PATH|TAB_SIZE #) (?: # BASIC # BASIC: Variable name, no brackets (?:(TM_[A-Z]+(?:_[A-Z]+)*)|([\d]))(?!\{) | # BRACKETED ([\{]) # BRACKETED: Variable name (?:(TM_[A-Z]+(?:_[A-Z]+)*)|([\d])) # BRACKETED: Post variable name expression (?: # Default keyword, single ([:].+?(?=[\}])) | # Default keyword, options ([\|].+?[\|](?=[\}])) | # Regular expression (?: ([\/]) (.+?(?=\/)) ([\/]) (.+?(?=\/)) ([\/]) # Flags # Not sure how to validate fully without back references? ([imx]{3}) (?=\}) ) | (?: ([\/]) ([^\/\}]+?) ( (?<![\\]{2}) [\/] ) ([^\/\}]+?) ( (?<![\\]{2}) [\/] ) # Flags # Not sure how to validate fully without back references? ([imx]{3}) ) | # Match to bracket (.+?(?=[\}]))? )? ([\}]) )
/
gmxX

Description

Regex pattern for Textmate Snippet variables with non-overlapping capture groups—for use with Highlight extension for VSCode.

Submitted by disk0 <www.github.com/disco0> - 4 years ago