Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Improve regular expressions #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 100 additions & 14 deletions grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2207,20 +2207,10 @@
]
'2':
'name': 'keyword.other.array.phpdoc.php'
'regex-double-quoted':
'begin': '"/(?=(\\\\.|[^"/])++/[imsxeADSUXu]*")'
'beginCaptures':
'0':
'name': 'punctuation.definition.string.begin.php'
'end': '(/)([imsxeADSUXu]*)(")'
'endCaptures':
'0':
'name': 'punctuation.definition.string.end.php'
'name': 'string.regexp.double-quoted.php'
'regex-double-quoted-interior':
'patterns': [
{
# Escaped from the regexp – there can also be 2 backslashes (since 1 will escape the first)
'match': '(\\\\){1,2}[.$^\\[\\]{}]'
'match': '\\\\[.$^\\[\\]{}*+()?|]'
'name': 'constant.character.escape.regex.php'
}
{
Expand All @@ -2236,23 +2226,119 @@
'name': 'string.regexp.arbitrary-repetition.php'
}
{
'begin': '\\[(?:\\^?\\])?'
'begin': '\\[\\^?\\]?'
'captures':
'0':
'name': 'punctuation.definition.character-class.php'
'end': '\\]'
'name': 'string.regexp.character-class.php'
'patterns': [
{
'match': '\\\\]'
}
{
'include': '#interpolation'
}
]
}
{
'match': '[$^+*]'
'match': '[$^+*|?.]'
'name': 'keyword.operator.regexp.php'
}
]
'regex-double-quoted':
'patterns': [
{
'match': '''(?x)
(")
[ \\t]*
([!"#$%&')*+,./:;=>?@\\]^_`|}~-])
(?!
(?:
\\\\[$"]
|
[^.$^\\[{*+(?|]
)+
\\2
[ \\t]*
[imsxeADSUXu]*
[ \\t]*
"
)
(
(?:
\\\\(?:"|\\2)
|
(?!"|\\2).
)++
)
\\2
[ \\t]*
[imsxeADSUXu]*
[ \\t]*
(")
'''
'captures':
'1':
'name': 'punctuation.definition.string.begin.php'
'4':
'name': 'punctuation.definition.string.end.php'
'3':
'patterns': [
{
'include': '#regex-double-quoted-interior'
}
]
'name': 'string.regexp.double-quoted.php'
}
{
'match': '''(?x)
(")
[ \\t]*
<
(?!
(?:
\\\\[$"]
|
[^|^$*+{\\[(".]
)+
>
[ \\t]*
[imsxeADSUXu]*
[ \\t]*
"
)
(
(
<
\\g<3>*
>
|
\\\\["<>]
|
[^"<>]
)++
)
>
[ \\t]*
[imsxeADSUXu]*
[ \\t]*
(")
'''
'captures':
'1':
'name': 'punctuation.definition.string.begin.php'
'4':
'name': 'punctuation.definition.string.end.php'
'2':
'patterns': [
{
'include': '#regex-double-quoted-interior'
}
]
'name': 'string.regexp.double-quoted.php'
}
]
'regex-single-quoted':
'begin': '\'/(?=(\\\\(?:\\\\(?:\\\\[\\\\\']?|[^\'])|.)|[^\'/])++/[imsxeADSUXu]*\')'
'beginCaptures':
Expand Down