%YAML 1.2 --- name: Regular Expressions (Python) comment: Matches Python's regular expression syntax. scope: source.regexp.python hidden: true contexts: main: - match: (#)[^]\[(){}^$+*?\\|"']*$ comment: We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags. scope: comment.line.number-sign.regexp captures: 1: punctuation.definition.comment.regexp - match: '\\[bBAZzG]|\^|\$' scope: keyword.control.anchor.regexp - match: '\\[1-9][0-9]?' scope: keyword.other.back-reference.regexp - match: '[?+*][?+]?|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??' scope: keyword.operator.quantifier.regexp - match: \| scope: keyword.operator.or.regexp - match: '\(\?\#' scope: punctuation.definition.comment.begin.regexp push: - meta_scope: comment.block.regexp - match: \) scope: punctuation.definition.comment.end.regexp pop: true - match: '\(\?[iLmsux]+\)' scope: keyword.other.option-toggle.regexp - match: '(\()(\?P=([a-zA-Z_][a-zA-Z_0-9]*\w*))(\))' scope: keyword.other.back-reference.named.regexp - match: (\()((\?=)|(\?!)|(\?<=)|(\?)|(\?:))?' captures: 1: punctuation.definition.group.begin.regexp 3: punctuation.definition.group.capture.regexp 4: entity.name.section.group.regexp 5: punctuation.definition.group.capture.regexp 6: punctuation.definition.group.no-capture.regexp push: - meta_scope: meta.group.regexp - match: \) scope: punctuation.definition.group.end.regexp pop: true - include: main - include: character-class character-class: - match: '\\[wWsSdDhH]|\.' scope: constant.character.character-class.regexp - match: \\. scope: constant.character.escape.backslash.regexp - match: '(\[)(\^)?' captures: 1: punctuation.definition.character-class.begin.regexp 2: keyword.operator.negation.regexp push: - meta_scope: constant.other.character-class.set.regexp - match: \] scope: punctuation.definition.character-class.end.regexp pop: true - include: character-class - match: '((\\.)|.)\-((\\.)|[^\]])' scope: constant.other.character-class.range.regexp captures: 2: constant.character.escape.backslash.regexp 4: constant.character.escape.backslash.regexp