Skip to content

Commit 8de7370

Browse files
author
James Brundage
committed
Updating RegexLiteral Transpiler (Fixes #257)
1 parent 3ae389a commit 8de7370

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Transpilers/Syntax/RegexLiteral.psx.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ $($Keywords -join '|') # followed by keywords
7575
(?<HereDoc>@){0,1} # Optional heredoc start
7676
['`"] # String start
7777
(?(HereDoc)([\r\n]{1,2})) # If we found a heredoc, the next portion of the match must be 1-2 newlines/carriage returns
78-
/ # Followed by a slash
78+
/
7979
'@, Options='IgnoreCase,IgnorePatternWhitespace')]
8080
[ValidatePattern(@'
81-
/ # closing slash
81+
/ # a closing slash
8282
(?<Options>[\w,]+){0,1} # optional options
8383
(?(HereDoc)([\r\n]{1,2})) # If we found a heredoc, the next portion of the match must be 1-2 newlines/carriage returns
8484
['`"]
@@ -114,7 +114,11 @@ process {
114114
$ExpandableStringExpression.Extent.ToString(), $ExpandableStringExpression.StringConstantType
115115
}
116116

117-
$sparseStringExpr = $StringExpr -replace $startRegex -replace $endRegex
117+
118+
$sparseStringExpr = $StringExpr -replace $endRegex -replace $startRegex
119+
if ($sparseStringExpr -match '^@{0,1}["'']') {
120+
return
121+
}
118122
$null = $StringExpr -match $endRegex
119123
$stringStart, $stringEnd =
120124
if ($stringType -eq 'SingleQuotedHereString') {

0 commit comments

Comments
 (0)