{ "name": "Regular Expression", "scopeName": "source.regexp", "patterns": [ { "include": "#main" } ], "repository": { "alternation": { "name": "keyword.operator.logical.or.regexp", "match": "\\|" }, "anchor": { "patterns": [ { "name": "keyword.control.anchor.line-start.regexp", "match": "\\^" }, { "name": "keyword.control.anchor.line-end.regexp", "match": "\\$" }, { "name": "keyword.control.anchor.string-start.regexp", "match": "\\\\A" }, { "name": "keyword.control.anchor.string-end-line.regexp", "match": "\\\\Z" }, { "name": "keyword.control.anchor.string-end.regexp", "match": "\\\\z" }, { "name": "keyword.control.anchor.search-start.regexp", "match": "\\\\G" }, { "name": "meta.unicode-boundary.regexp", "match": "(?:(\\\\b)|(\\\\B))(\\{)(\\w+)(})", "captures": { "1": { "name": "keyword.control.anchor.word-boundary.regexp" }, "2": { "name": "keyword.control.anchor.non-word-boundary.regexp" }, "3": { "name": "punctuation.definition.unicode-boundary.bracket.curly.begin.regexp" }, "4": { "name": "entity.property.name.regexp" }, "5": { "name": "punctuation.definition.unicode-boundary.bracket.curly.end.regexp" } } }, { "name": "keyword.control.anchor.word-boundary.regexp", "match": "\\\\b" }, { "name": "keyword.control.anchor.non-word-boundary.regexp", "match": "\\\\B" } ] }, "assertion": { "patterns": [ { "name": "meta.assertion.positive.look-ahead.regexp", "begin": "\\(\\?=", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.assertion.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.assertion.end.regexp" } } }, { "name": "meta.assertion.negative.look-ahead.regexp", "begin": "\\(\\?!", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.assertion.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.assertion.end.regexp" } } }, { "name": "meta.assertion.negative.look-behind.regexp", "begin": "\\(\\?\u003c!", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.assertion.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.assertion.end.regexp" } } }, { "name": "meta.assertion.positive.look-behind.regexp", "begin": "\\(\\?\u003c=", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.assertion.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.assertion.end.regexp" } } } ] }, "class": { "name": "meta.character-class.set.regexp", "begin": "\\[", "end": "\\]", "patterns": [ { "include": "#classInnards" } ], "beginCaptures": { "0": { "name": "punctuation.definition.character-class.set.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.character-class.set.end.regexp" } } }, "classInnards": { "patterns": [ { "name": "keyword.operator.logical.not.regexp", "match": "\\G\\^" }, { "name": "constant.character.escape.backspace.regexp", "match": "\\\\b" }, { "begin": "(\u0026\u0026)(\\[)", "end": "\\]", "patterns": [ { "include": "#classInnards" } ], "beginCaptures": { "1": { "name": "keyword.operator.logical.intersect.regexp" }, "2": { "name": "punctuation.definition.character-class.set.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.character-class.set.end.regexp" } } }, { "name": "keyword.operator.logical.intersect.regexp", "match": "\u0026\u0026" }, { "name": "punctuation.separator.range.dash.regexp", "match": "(?\u003c!\\G|\\\\[dwshDWSHN])-(?!\\])" }, { "name": "constant.language.posix.$2-char.character-class.regexp", "match": "(\\[:)(\\^?)(\\w+)(:\\])", "captures": { "1": { "name": "punctuation.definition.character-class.set.begin.regexp" }, "2": { "name": "keyword.operator.logical.not.regexp" }, "3": { "name": "support.constant.posix-class.regexp" }, "4": { "name": "punctuation.definition.character-class.set.end.regexp" } } }, { "name": "constant.character.escape.backslash.regexp", "match": "\\\\\\[|\\\\\\]" }, { "match": "\\^|\\$|\\(|\\)|\\[" }, { "include": "#escape" }, { "include": "$self" }, { "name": "constant.single.character.character-class.regexp", "match": "[^\\]]" } ] }, "comment": { "name": "comment.block.regexp", "begin": "\\(\\?#", "end": "\\)", "patterns": [ { "name": "constant.character.escape.backslash.regexp", "match": "\\\\." } ] }, "conditional": { "name": "meta.conditional.regexp", "begin": "(\\()(\\?)(?=\\()", "end": "\\)", "patterns": [ { "name": "punctuation.separator.condition.if-else.regexp", "match": "\\|" }, { "include": "#assertion" }, { "name": "meta.condition.function-call.regexp", "begin": "\\G\\(", "end": "\\)", "patterns": [ { "name": "storage.type.function.subpattern.regexp", "match": "\\GDEFINE" }, { "name": "keyword.other.assertion.regexp", "match": "\\Gassert" }, { "match": "\\G(?:(\u003c)([^\u003e]+)(\u003e)|(')([^\u003e]+)('))", "captures": { "1": { "name": "punctuation.definition.group-reference.bracket.angle.begin.regexp" }, "2": { "name": "entity.group.name.regexp" }, "3": { "name": "punctuation.definition.group-reference.bracket.angle.end.regexp" }, "4": { "name": "punctuation.definition.group-reference.quote.single.begin.regexp" }, "5": { "name": "entity.group.name.regexp" }, "6": { "name": "punctuation.definition.group-reference.quote.single.end.regexp" } } }, { "match": "\\G(R(\u0026))(\\w+)", "captures": { "1": { "name": "keyword.other.recursion.specific.regexp" }, "2": { "name": "punctuation.definition.reference.regexp" }, "3": { "name": "entity.group.name.regexp" } } }, { "name": "keyword.other.recursion.specific-group.regexp", "match": "\\GR\\d+" }, { "name": "keyword.other.recursion.overall.regexp", "match": "\\GR" }, { "name": "keyword.other.reference.absolute.regexp", "match": "\\G\\d+" }, { "name": "keyword.other.reference.relative.regexp", "match": "\\G[-+]\\d+" }, { "name": "entity.group.name.regexp", "match": "\\G\\w+" } ], "beginCaptures": { "0": { "name": "punctuation.section.condition.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.section.condition.end.regexp" } } }, { "include": "#main" } ], "beginCaptures": { "1": { "name": "punctuation.section.condition.begin.regexp" }, "2": { "name": "keyword.control.flow.regexp" } }, "endCaptures": { "0": { "name": "punctuation.section.condition.end.regexp" } } }, "escape": { "patterns": [ { "name": "constant.character.escape.decimal.regexp", "match": "\\\\d" }, { "name": "constant.character.escape.whitespace.regexp", "match": "\\\\s" }, { "name": "constant.character.escape.word-char.regexp", "match": "\\\\w" }, { "name": "constant.character.escape.newline.regexp", "match": "\\\\n" }, { "name": "constant.character.escape.tab.regexp", "match": "\\\\t" }, { "name": "constant.character.escape.return.regexp", "match": "\\\\r" }, { "name": "constant.character.escape.non-decimal.regexp", "match": "\\\\D" }, { "name": "constant.character.escape.non-whitespace.regexp", "match": "\\\\S" }, { "name": "constant.character.escape.non-word-char.regexp", "match": "\\\\W" }, { "name": "constant.character.escape.alarm.regexp", "match": "\\\\a" }, { "name": "constant.character.escape.escape-char.regexp", "match": "\\\\e" }, { "name": "constant.character.escape.form-feed.regexp", "match": "\\\\f" }, { "name": "constant.character.escape.vertical-tab.regexp", "match": "\\\\v" }, { "name": "constant.character.escape.numeric.regexp", "match": "\\\\x[0-9A-Fa-f]{2}" }, { "name": "meta.character-escape.hex.regexp", "match": "(\\\\x)(\\{)([0-9A-Fa-f]{2,})(\\})", "captures": { "1": { "name": "keyword.operator.unicode-escape.hex.regexp" }, "2": { "name": "punctuation.definition.unicode-escape.bracket.curly.begin.regexp" }, "3": { "name": "constant.numeric.codepoint.hex.regexp" }, "4": { "name": "punctuation.definition.unicode-escape.bracket.curly.end.regexp" } } }, { "name": "meta.character-escape.octal.regexp", "match": "(\\\\o)(\\{)(\\d{2,})(\\})", "captures": { "1": { "name": "keyword.operator.unicode-escape.octal.regexp" }, "2": { "name": "punctuation.definition.unicode-escape.bracket.curly.begin.regexp" }, "3": { "name": "constant.numeric.codepoint.octal.regexp" }, "4": { "name": "punctuation.definition.unicode-escape.bracket.curly.end.regexp" } } }, { "name": "meta.unicode-property.regexp", "match": "(\\\\[Pp])(\\{)(\\^?)([^{}]+)(\\})", "captures": { "1": { "name": "keyword.operator.unicode-property.regexp" }, "2": { "name": "punctuation.definition.unicode-escape.bracket.curly.begin.regexp" }, "3": { "name": "keyword.operator.logical.not.regexp" }, "4": { "name": "entity.property.name.regexp", "patterns": [ { "include": "#propInnards" } ] }, "5": { "name": "punctuation.definition.unicode-escape.bracket.curly.end.regexp" } } }, { "name": "meta.unicode-property.single-letter.regexp", "match": "(\\\\[Pp])(\\w)", "captures": { "1": { "name": "keyword.operator.unicode-property.regexp" }, "2": { "name": "entity.property.name.regexp" } } }, { "name": "meta.group-reference.regexp", "contentName": "entity.group.name.regexp", "begin": "(\\\\[kg])(\u003c)", "end": "\u003e", "patterns": [ { "include": "#groupRefInnards" } ], "beginCaptures": { "1": { "name": "keyword.operator.group-reference.regexp" }, "2": { "name": "punctuation.definition.group-reference.bracket.angle.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group-reference.bracket.angle.end.regexp" } } }, { "name": "meta.group-reference.regexp", "contentName": "entity.group.name.regexp", "begin": "(\\\\[kg])(')", "end": "'", "patterns": [ { "include": "#groupRefInnards" } ], "beginCaptures": { "1": { "name": "keyword.operator.group-reference.regexp" }, "2": { "name": "punctuation.definition.group-reference.quote.single.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group-reference.quote.single.end.regexp" } } }, { "name": "meta.group-reference.regexp", "contentName": "entity.group.name.regexp", "begin": "(\\\\[kg])({)", "end": "}", "beginCaptures": { "1": { "name": "keyword.operator.group-reference.regexp" }, "2": { "name": "punctuation.definition.group-reference.bracket.curly.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group-reference.bracket.curly.end.regexp" } } }, { "name": "meta.group-reference.single-letter.regexp", "match": "(\\\\g)(\\d)", "captures": { "1": { "name": "keyword.operator.group-reference.regexp" }, "2": { "name": "entity.group.name.regexp" } } }, { "name": "meta.named-char.regexp", "match": "(\\\\N)(\\{)([^{}]+)(\\})", "captures": { "1": { "name": "keyword.operator.named-char.regexp" }, "2": { "name": "punctuation.definition.unicode-escape.bracket.curly.begin.regexp" }, "3": { "name": "entity.character.name.regexp", "patterns": [ { "name": "punctuation.separator.colon.regexp", "match": ":" }, { "name": "punctuation.separator.codepoint.regexp", "match": "(?\u003c=U)\\+(?=[A-Fa-f0-9])" } ] }, "4": { "name": "punctuation.definition.unicode-escape.bracket.curly.end.regexp" } } }, { "name": "constant.character.escape.octal.numeric.regexp", "match": "\\\\(?:\\d{3}|0\\d)" }, { "name": "constant.character.escape.null-byte.numeric.regexp", "match": "\\\\0" }, { "name": "keyword.other.back-reference.$1.regexp", "match": "\\\\(\\d{1,2})" }, { "name": "constant.character.escape.control-char.regexp", "match": "\\\\(?:c|C-)[?-_]" }, { "name": "constant.character.escape.hex-digit.regexp", "match": "\\\\h" }, { "name": "constant.character.escape.non-hex-digit.regexp", "match": "\\\\H" }, { "name": "keyword.control.end-mode.regexp", "match": "\\\\E" }, { "name": "keyword.control.quote-mode.regexp", "match": "\\\\Q" }, { "name": "keyword.control.foldcase-mode.regexp", "match": "\\\\F" }, { "name": "keyword.control.lowercase-mode.regexp", "match": "\\\\L" }, { "name": "keyword.control.titlecase-mode.regexp", "match": "\\\\U" }, { "name": "keyword.control.keep-out.regexp", "match": "\\\\K" }, { "name": "constant.character.escape.lowercase-next.regexp", "match": "\\\\l" }, { "name": "constant.character.escape.titlecase-next.regexp", "match": "\\\\u" }, { "name": "constant.character.escape.non-newline.regexp", "match": "\\\\N" }, { "name": "constant.character.escape.extended-grapheme.regexp", "match": "\\\\X" }, { "name": "constnat.character.escape.linebreak-grapheme.regexp", "match": "\\\\R" }, { "name": "constant.character.escape.non-vertical-whitespace.regexp", "match": "\\\\V" }, { "name": "constant.character.escape.meta-control.regexp", "match": "\\\\M-\\\\C-[?-_]" }, { "name": "constant.character.escape.meta-char.regexp", "match": "\\\\M-." }, { "name": "constant.character.escape.misc.regexp", "match": "\\\\." } ] }, "group": { "patterns": [ { "name": "meta.callout.regexp", "match": "(\\()(\\?C\\d*)(\\))", "captures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "name": "keyword.control.callout.regexp" }, "3": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.group.named.regexp", "begin": "\\(\\?(?=P?[\u003c'])", "end": "\\)", "patterns": [ { "contentName": "entity.group.name.regexp", "begin": "\\G(P?)(\u003c)", "end": "\u003e", "beginCaptures": { "1": { "name": "storage.type.function.named-group.regexp" }, "2": { "name": "punctuation.definition.named-group.bracket.angle.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.named-group.bracket.angle.end.regexp" } } }, { "contentName": "entity.group.name.regexp", "begin": "\\G'", "end": "'", "beginCaptures": { "0": { "name": "punctuation.definition.named-group.quote.single.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.named-group.quote.single.end.regexp" } } }, { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.group.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.group.non-capturing.regexp", "begin": "(\\(\\?)([-A-Za-z^]*)(:)", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "patterns": [ { "include": "#scopedModifiers" } ] }, "3": { "name": "punctuation.separator.colon.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.group.atomic.regexp", "begin": "\\(\\?\u003e", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.group.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.group.scoped-modifiers.regexp", "match": "(\\(\\?)([-A-Za-z^]*)(\\))", "captures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "patterns": [ { "include": "#scopedModifiers" } ] }, "3": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.control-verb.regexp", "match": "(\\(\\*)(\\w*)(?:([:=])([^\\s()]*))?(\\))", "captures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "name": "keyword.control.verb.regexp" }, "3": { "name": "punctuation.separator.key-value.regexp" }, "4": { "name": "variable.parameter.control-verb.regexp" }, "5": { "name": "punctuation.definition.group.begin.regexp" } } }, { "name": "meta.group-reference.named.regexp", "match": "(\\()(\\?(?:\u0026|P[\u003e=]))(\\w+)(\\))", "captures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "name": "keyword.other.back-reference.regexp" }, "3": { "name": "entity.group.name.regexp" }, "4": { "name": "punctuation.definition.group.begin.regexp" } } }, { "name": "meta.group-reference.relative.regexp", "match": "(\\()(\\?[-+]\\d+)(\\))", "captures": { "1": { "name": "punctuation.definition.group.begin.regexp" }, "2": { "name": "keyword.other.back-reference.regexp" }, "3": { "name": "punctuation.definition.group.end.regexp" } } }, { "name": "meta.group.regexp", "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#main" } ], "beginCaptures": { "0": { "name": "punctuation.definition.group.begin.regexp" } }, "endCaptures": { "0": { "name": "punctuation.definition.group.end.regexp" } } } ] }, "groupRefInnards": { "patterns": [ { "name": "keyword.operator.arithmetic.minus.regexp", "match": "\\-(?=\\d)" }, { "name": "keyword.operator.arithmetic.plus.regexp", "match": "\\+(?=\\d)" } ] }, "main": { "patterns": [ { "include": "#comment" }, { "include": "#variable" }, { "include": "#anchor" }, { "include": "#escape" }, { "include": "#wildcard" }, { "include": "#alternation" }, { "include": "#quantifier" }, { "include": "#assertion" }, { "include": "#conditional" }, { "include": "#group" }, { "include": "#class" } ] }, "propInnards": { "patterns": [ { "name": "keyword.operator.comparison.regexp", "match": "=" }, { "name": "constant.language.boolean.${0:/downcase}.regexp", "match": "True|False" } ] }, "quantifier": { "patterns": [ { "name": "keyword.operator.quantifier.regexp", "match": "[*+?]" }, { "name": "keyword.operator.quantifier.specific.regexp", "match": "(\\{)(?:(\\d+)(,?)(\\d*)|(,)(\\d+))(\\})", "captures": { "1": { "name": "punctuation.definition.quantifier.bracket.curly.begin.regexp" }, "2": { "name": "keyword.operator.quantifier.min.regexp" }, "3": { "name": "punctuation.delimiter.comma.regexp" }, "4": { "name": "keyword.operator.quantifier.max.regexp" }, "5": { "name": "punctuation.delimiter.comma.regexp" }, "6": { "name": "keyword.operator.quantifier.max.regexp" }, "7": { "name": "punctuation.definition.quantifier.bracket.curly.end.regexp" } } } ] }, "scopedModifiers": { "patterns": [ { "name": "keyword.operator.modifier.reset.regexp", "match": "(?\u003c=\\?)\\^" }, { "name": "keyword.operator.modifier.negate.regexp", "match": "-" }, { "name": "storage.modifier.flag.$0.regexp", "match": "[A-Za-z]" } ] }, "variable": { "patterns": [ { "name": "variable.other.regexp", "match": "(?\u003c![^\\\\]\\\\|^\\\\)\\$(?!\\d|-)[-\\w]+", "captures": { "1": { "name": "punctuation.definition.variable.regexp" } } }, { "name": "variable.other.bracket.regexp", "match": "(?\u003c![^\\\\]\\\\|^\\\\)(\\$\\{)\\s*(?!\\d|-)[-\\w]+\\s*(\\})", "captures": { "1": { "name": "punctuation.definition.variable.begin.tmcg" }, "2": { "name": "punctuation.definition.variable.end.tmcg" } } } ] }, "wildcard": { "name": "constant.character.wildcard.dot.match.any.regexp", "match": "\\." } } }