Skip to content

Commit 839824f

Browse files
StartAutomatingStartAutomating
authored andcommitted
Updating PipeScript.HelpOut.ps1 (#56)
1 parent 35c834a commit 839824f

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

docs/RegexLiteral.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
RegexLiteral
3+
------------
4+
### Synopsis
5+
Regex Literal Transpiler
6+
7+
---
8+
### Description
9+
10+
Allows for Regex Literals within PipeScript.
11+
12+
Regex Literals are strings enclosed within slashes.
13+
14+
The ending slash may be followed by ```[Text.RegularExpressions.RegexOptions]```.
15+
16+
---
17+
### Examples
18+
#### EXAMPLE 1
19+
```PowerShell
20+
{
21+
'/[a|b]/'
22+
} | .>PipeScript
23+
```
24+
# This will become:
25+
26+
[regex]::new('[a|b]', 'IgnoreCase')
27+
#### EXAMPLE 2
28+
```PowerShell
29+
{
30+
"/[$a|$b]/"
31+
} | .>PipeScript
32+
```
33+
# This will become:
34+
35+
[regex]::new("[$a|$b]", 'IgnoreCase')
36+
#### EXAMPLE 3
37+
```PowerShell
38+
{
39+
@'
40+
/
41+
# Heredocs Regex literals will have IgnorePatternWhitespace by default, which allows comments
42+
^ # Match the string start
43+
(?<indent>\s{0,1})
44+
/
45+
'@
46+
} | .>PipeScript
47+
```
48+
# This will become:
49+
50+
[regex]::new(@'
51+
# Heredocs Regex literals will have IgnorePatternWhitespace by default, which allows comments
52+
^ # Match the string start
53+
(?<indent>\s{0,1})
54+
'@, 'IgnorePatternWhitespace,IgnoreCase')
55+
#### EXAMPLE 4
56+
```PowerShell
57+
$Keywords = "looking", "for", "these", "words"
58+
```
59+
{
60+
@"
61+
/
62+
# Double quoted heredocs can still contain variables
63+
[\s\p{P}]{0,1} # Whitespace or punctuation
64+
$($Keywords -join '|') # followed by keywords
65+
[\s\p{P}]{0,1} # followed by whitespace or punctuation
66+
/
67+
"@
68+
} | .>PipeScript
69+
70+
71+
# This will become:
72+
73+
[regex]::new(@"
74+
# Double quoted heredocs can still contain variables
75+
[\s\p{P}]{0,1} # Whitespace or punctuation
76+
$($Keywords -join '|') # followed by keywords
77+
[\s\p{P}]{0,1} # followed by whitespace or punctuation
78+
"@, 'IgnorePatternWhitespace,IgnoreCase')
79+
---
80+
### Parameters
81+
#### **StringConstantExpression**
82+
83+
|Type |Requried|Postion|PipelineInput |
84+
|-----------------------------------|--------|-------|--------------|
85+
|```[StringConstantExpressionAst]```|true |named |true (ByValue)|
86+
---
87+
#### **ExpandableStringExpression**
88+
89+
|Type |Requried|Postion|PipelineInput |
90+
|-------------------------------------|--------|-------|--------------|
91+
|```[ExpandableStringExpressionAst]```|true |named |true (ByValue)|
92+
---
93+
### Syntax
94+
```PowerShell
95+
RegexLiteral -StringConstantExpression <StringConstantExpressionAst> [<CommonParameters>]
96+
```
97+
```PowerShell
98+
RegexLiteral -ExpandableStringExpression <ExpandableStringExpressionAst> [<CommonParameters>]
99+
```
100+
---
101+
102+

0 commit comments

Comments
 (0)