Skip to content

Commit 1bf011a

Browse files
author
James Brundage
committed
Updating RegexLiteral Examples
1 parent d7cd5f8 commit 1bf011a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Transpilers/Syntax/RegexLiteral.psx.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
# This will become:
2424
25-
[regex]::new("[$a|$b]", 'IgnoreCase'
25+
[regex]::new("[$a|$b]", 'IgnoreCase')
2626
.EXAMPLE
2727
{
2828
@'
@@ -34,9 +34,18 @@
3434
'@
3535
} | .>PipeScript
3636
37+
# This will become:
38+
39+
[regex]::new(@'
40+
# Heredocs Regex literals will have IgnorePatternWhitespace by default, which allows comments
41+
^ # Match the string start
42+
(?<indent>\s{0,1})
43+
'@, 'IgnorePatternWhitespace,IgnoreCase')
44+
3745
.EXAMPLE
46+
$Keywords = "looking", "for", "these", "words"
47+
3848
{
39-
$Keywords = "looking", "for", "these", "words"
4049
@"
4150
/
4251
# Double quoted heredocs can still contain variables
@@ -46,6 +55,16 @@ $($Keywords -join '|') # followed by keywords
4655
/
4756
"@
4857
} | .>PipeScript
58+
59+
60+
# This will become:
61+
62+
[regex]::new(@"
63+
# Double quoted heredocs can still contain variables
64+
[\s\p{P}]{0,1} # Whitespace or punctuation
65+
$($Keywords -join '|') # followed by keywords
66+
[\s\p{P}]{0,1} # followed by whitespace or punctuation
67+
"@, 'IgnorePatternWhitespace,IgnoreCase')
4968
#>
5069
[ValidatePattern(@'
5170
^ # Start anchor

0 commit comments

Comments
 (0)