Skip to content

Commit 2bf9875

Browse files
Merge pull request #87 from StartAutomating/RenameWriteRegex
Rename WriteRegex
2 parents 3025cff + 5491e96 commit 2bf9875

10 files changed

+121
-97
lines changed

CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
0.6.3
1+
0.6.4
2+
---
3+
* Renaming Write-RegEx to New-RegEx (#66) ** Write-RegEx will remain aliased until at least 0.7**
4+
* Fixing Issue in Embedding (#82)
5+
* Improving -Extract by auto-detecting data types (#81)
6+
* ?<FFMpeg_Progress> - Fixing capture name (#80)
7+
* Adding ?<FFMpeg_Configuration> (#83)
8+
* Adding ?<FFMpeg_Stream> (#83)
9+
* Adding ?<FFMpeg_Input> (#83)
10+
* Adding ?<FFMpeg_Output> (#83)
11+
* Adding ?<FFMpeg_Metadata> (#83)
12+
13+
0.6.3
214
---
315
New Regular Expressions:
416
* ?<CNC_GCode> (Fixes #76)

Get-RegEx.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.Link
2424
Use-RegEx
2525
.Link
26-
Write-RegEx
26+
New-RegEx
2727
#>
2828
[OutputType([PSObject])]
2929
param(

Import-RegEx.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.Link
1515
Use-RegEx
1616
.Link
17-
Write-RegEx
17+
New-RegEx
1818
#>
1919
[OutputType([nullable], [PSObject])]
2020
param(

Irregular.psd1

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.6.3'
2+
ModuleVersion = '0.6.4'
33
RootModule = 'Irregular.psm1'
44
Description = 'Regular Expressions made Strangely Simple'
55
FormatsToProcess = 'Irregular.format.ps1xml'
@@ -15,6 +15,18 @@
1515
IconURI = 'https://github.com/StartAutomating/Irregular/blob/master/Assets/Irregular_600_Square.png'
1616
}
1717
ReleaseNotes = @'
18+
0.6.4
19+
---
20+
* Renaming Write-RegEx to New-RegEx (#66) ** Write-RegEx will remain aliased until at least 0.7**
21+
* Fixing Issue in Embedding (#82)
22+
* Improving -Extract by auto-detecting data types (#81)
23+
* ?<FFMpeg_Progress> - Fixing capture name (#80)
24+
* Adding ?<FFMpeg_Configuration> (#83)
25+
* Adding ?<FFMpeg_Stream> (#83)
26+
* Adding ?<FFMpeg_Input> (#83)
27+
* Adding ?<FFMpeg_Output> (#83)
28+
* Adding ?<FFMpeg_Metadata> (#83)
29+
1830
0.6.3
1931
---
2032
New Regular Expressions:

Irregular.psm1

50 Bytes
Binary file not shown.

Irregular.tests.ps1

+54-54
Original file line numberDiff line numberDiff line change
@@ -278,31 +278,31 @@ describe Use-Regex {
278278

279279
context 'Special Piping Behavior' {
280280
it 'Will match the contents if piped in a file' {
281-
(Get-Command Write-RegEx |
281+
(Get-Command New-RegEx |
282282
Select-Object -ExpandProperty ScriptBlock |
283283
Select-Object -ExpandProperty File) -as [IO.FileInfo] |
284284
?<PowerShell_HelpField> |
285285
Select-Object -ExpandProperty InputObject |
286286
Select-Object -ExpandProperty Name |
287-
should -Be Write-Regex.ps1
287+
should -Be New-RegEx.ps1
288288
}
289289

290290
it 'Will match the script contents if passed an external script' {
291-
Get-Command ((Get-Command Write-RegEx |
291+
Get-Command ((Get-Command New-RegEx |
292292
Select-Object -ExpandProperty ScriptBlock |
293293
Select-Object -ExpandProperty File)) |
294294
?<PowerShell_HelpField> |
295295
Select-Object -ExpandProperty InputObject |
296296
Select-Object -ExpandProperty Name |
297-
should -Be Write-Regex.ps1
297+
should -Be New-RegEx.ps1
298298
}
299299

300300
it 'Will match the definition if passed a function' {
301-
Get-Command Write-RegEx |
301+
Get-Command New-RegEx |
302302
?<PowerShell_HelpField> |
303303
Select-Object -ExpandProperty InputObject |
304304
Select-Object -ExpandProperty Name |
305-
should -Be Write-RegEx
305+
should -Be New-RegEx
306306
}
307307
}
308308

@@ -353,62 +353,62 @@ describe Use-Regex {
353353
}
354354

355355

356-
describe Write-Regex {
356+
describe New-RegEx {
357357
it "Helps you write -CharacterClasses" {
358-
Write-RegEx -CharacterClass LowerCaseLetter |
358+
New-RegEx -CharacterClass LowerCaseLetter |
359359
Select-Object -ExpandProperty Pattern |
360360
should -Be '\p{Ll}'
361361
}
362362
it "Lets you look for repeated content" {
363-
Write-RegEx -CharacterClass Digit -Repeat |
363+
New-RegEx -CharacterClass Digit -Repeat |
364364
Select-Object -ExpandProperty Pattern |
365365
should -Be '\d+'
366366
}
367367

368368

369369

370370
it "Simplifies lookahead with -Before (aka -LookAhead)" {
371-
Write-RegEx -Expression 'q' -LookAhead u | # Matches a q that is followed by a u
371+
New-RegEx -Expression 'q' -LookAhead u | # Matches a q that is followed by a u
372372
Select-Object -ExpandProperty Pattern |
373373
should -Be 'q(?=u)'
374374
}
375375

376376
it 'Simplifies lookbehind with -After (aka -LookBehind)' {
377-
Write-RegEx -Expression u -LookBehind q | # Matches a u that is preceeded by a q
377+
New-RegEx -Expression u -LookBehind q | # Matches a u that is preceeded by a q
378378
Select-Object -ExpandProperty Pattern |
379379
should -Be '(?<=q)u'
380380
}
381381

382382
it 'Simplifies negative lookahead with -NotBefore' {
383-
Write-RegEx -Expression q -NotBefore u | # Matches a q that isn't followed by a u
383+
New-RegEx -Expression q -NotBefore u | # Matches a q that isn't followed by a u
384384
Select-Object -ExpandProperty Pattern |
385385
should -Be 'q(?!u)'
386386
}
387387

388388

389389
it "Simplifies negative lookbehind with -NotAfter (aka -NegativeLookBehind)" {
390-
Write-RegEx -Expression '"' -NegativeLookBehind '\\' |
390+
New-RegEx -Expression '"' -NegativeLookBehind '\\' |
391391
Select-Object -ExpandProperty Pattern |
392392
should -Be '(?<!\\)"'
393393
}
394394
it "Can pipe to itself to compound expressions" {
395-
Write-RegEx -Pattern '"' |
396-
Write-RegEx -CharacterClass Any -Repeat -Lazy -Before (
397-
Write-RegEx -Pattern '"' -NotAfter '\\|`'
395+
New-RegEx -Pattern '"' |
396+
New-RegEx -CharacterClass Any -Repeat -Lazy -Before (
397+
New-RegEx -Pattern '"' -NotAfter '\\|`'
398398
) |
399-
Write-RegEx -Pattern '"' |
399+
New-RegEx -Pattern '"' |
400400
Select-Object -ExpandProperty Pattern |
401401
should -Be '".+?(?=(?<!\\|`)")"'
402402
}
403403

404404
it 'Can combine more than on -CharacterClass' {
405-
Write-RegEx -CharacterClass Digit, Word |
405+
New-RegEx -CharacterClass Digit, Word |
406406
Select-Object -ExpandProperty Pattern |
407407
should -Be '[\d\w]'
408408
}
409409

410410
it 'Can negate a -CharacterClass' {
411-
Write-RegEx -CharacterClass Digit, Word -Not |
411+
New-RegEx -CharacterClass Digit, Word -Not |
412412
Select-Object -ExpandProperty Pattern |
413413
should -Be '[^\d\w]'
414414
}
@@ -420,126 +420,126 @@ describe Write-Regex {
420420
}
421421

422422
it 'Can negate a -LiteralCharacter' {
423-
Write-Regex -LiteralCharacter '.' -Not | Should -Be '[^\.]'
423+
New-RegEx -LiteralCharacter '.' -Not | Should -Be '[^\.]'
424424
}
425425

426426
it 'Can use a -StartAnchor or -EndAnchor' {
427-
Write-RegEx -CharacterClass Whitespace -Min 0 -StartAnchor LineStart -EndAnchor LineEnd |
427+
New-RegEx -CharacterClass Whitespace -Min 0 -StartAnchor LineStart -EndAnchor LineEnd |
428428
Select-Object -ExpandProperty Pattern |
429429
should -Be '^\s{0,}$'
430430
}
431431

432432
it 'Can check for -Min and -Max occurances' {
433-
Write-RegEx -CharacterClass Whitespace -Min 0 -Max 4 |
433+
New-RegEx -CharacterClass Whitespace -Min 0 -Max 4 |
434434
Select-Object -ExpandProperty Pattern |
435435
should -Be '\s{0,4}'
436436
}
437437

438438
it 'Can leave a comment' {
439-
Write-RegEx -CharacterClass Whitespace -Comment "Whitespace" |
439+
New-RegEx -CharacterClass Whitespace -Comment "Whitespace" |
440440
Select-Object -ExpandProperty Pattern |
441441
should -BeLike "\s # Whitespace*"
442442
}
443443

444444
it 'Can write a description' {
445-
Write-RegEx -CharacterClass Whitespace -Description "Whitespace" |
445+
New-RegEx -CharacterClass Whitespace -Description "Whitespace" |
446446
Select-Object -ExpandProperty Pattern |
447447
should -Be "# Whitespace$([Environment]::NewLine)\s"
448448
}
449449

450450
it 'Can name a capture' {
451-
Write-RegEx -Name Digits -CharacterClass Digit -Repeat |
451+
New-RegEx -Name Digits -CharacterClass Digit -Repeat |
452452
Select-Object -ExpandProperty Pattern |
453453
should -Be '(?<Digits>\d+)'
454454
}
455455

456456
it 'Can write an expression that will always fail' {
457-
Write-RegEx -Not | select -ExpandProperty Pattern | should -Be '(?!)'
457+
New-RegEx -Not | select -ExpandProperty Pattern | should -Be '(?!)'
458458
}
459459

460460
it 'Can write an anti expression' {
461-
Write-RegEx -Not foo | Select-Object -ExpandProperty pattern | should -Be '\A((?!(foo)).)*\Z'
461+
New-RegEx -Not foo | Select-Object -ExpandProperty pattern | should -Be '\A((?!(foo)).)*\Z'
462462
}
463463

464464
it 'Can Be -Atomic' {
465-
Write-RegEx -Atomic -Pattern 'do', 'die' -Or | select-object -expand Pattern | should -BeLike '(?>*do*|*die*)'
465+
New-RegEx -Atomic -Pattern 'do', 'die' -Or | select-object -expand Pattern | should -BeLike '(?>*do*|*die*)'
466466
}
467467

468468
it 'Can Be -Greedy or -Lazy (or both)' {
469-
Write-RegEx -Pattern '(.|\s)' -Greedy -Lazy | Select-Object -ExpandProperty Pattern | Should -Be '(.|\s)*?'
469+
New-RegEx -Pattern '(.|\s)' -Greedy -Lazy | Select-Object -ExpandProperty Pattern | Should -Be '(.|\s)*?'
470470
}
471471

472472
it "Doesn't have to capture (with -NoCapture)" {
473-
Write-RegEx -NoCapture '\d+' |
473+
New-RegEx -NoCapture '\d+' |
474474
Select-Object -ExpandProperty Pattern | should -Be '(?:\d+)'
475475
}
476476

477477
it 'Can -Be optional' {
478-
Write-RegEx -Pattern do, die -Or -Optional | select-object -expand Pattern | should -BeLike '(?:*do*|*die*)?'
478+
New-RegEx -Pattern do, die -Or -Optional | select-object -expand Pattern | should -BeLike '(?:*do*|*die*)?'
479479
}
480480

481481
it 'Can use Saved Expressions (with the format ?<Name>)' {
482-
Write-RegEx ?<Digits> | Select-Object -ExpandProperty Pattern | should -BeLike '*\d+*'
482+
New-RegEx ?<Digits> | Select-Object -ExpandProperty Pattern | should -BeLike '*\d+*'
483483
}
484484

485485
it 'Can write conditionals' {
486-
Write-RegEx '((?<Digit>\d)|(?<NotDigit>\D))' -If Digit -Then '\D' -Else '\d' |
486+
New-RegEx '((?<Digit>\d)|(?<NotDigit>\D))' -If Digit -Then '\D' -Else '\d' |
487487
Use-RegEx -IsMatch 'a1' |
488488
should -Be $true
489-
Write-RegEx '(?<Digit>\d)' |
490-
Write-RegEx -If Digit -Then '[abcdef]'
489+
New-RegEx '(?<Digit>\d)' |
490+
New-RegEx -If Digit -Then '[abcdef]'
491491
}
492492

493493
it 'Can write backreferences' {
494-
Write-RegEx -Backreference previousCapture |
494+
New-RegEx -Backreference previousCapture |
495495
Select-Object -ExpandProperty Pattern |
496496
Should -Be '\k<previousCapture>'
497497

498-
$(Write-RegEx -Backreference 1).ToString() |
498+
$(New-RegEx -Backreference 1).ToString() |
499499
Should -Be '\1'
500500
}
501501

502502
it 'Can refer to other saved captures in a pattern (by putting ?<CaptureName> without leading comments)' {
503-
Write-RegEx -Pattern '?<Digits>' |
503+
New-RegEx -Pattern '?<Digits>' |
504504
Use-RegEx -IsMatch -Match 1 |
505505
should -Be true
506506
}
507507

508508
it 'Can rename a saved capture (by putting (?<NewCaptureName>?<OldCaptureName>)' {
509-
Write-RegEx -Pattern '(?<MyDigits>?<Digits>)' |
509+
New-RegEx -Pattern '(?<MyDigits>?<Digits>)' |
510510
Use-RegEx -Extract -Match 1 |
511511
Select-Object -ExpandProperty MyDigits |
512512
should -Be 1
513513
}
514514

515515
it 'Can match -Until a pattern' {
516-
$writeRegexCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Write-Regex','Function')
516+
$writeRegexCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand('New-RegEx','Function')
517517

518-
Write-RegEx -Pattern \<\# |
519-
Write-RegEx -Name Block -Until \#> |
520-
Write-RegEx -Pattern \#\> |
518+
New-RegEx -Pattern \<\# |
519+
New-RegEx -Name Block -Until \#> |
520+
New-RegEx -Pattern \#\> |
521521
Use-RegEx -Extract -Match $writeRegexCmd.Definition |
522522
Select-Object -ExpandProperty Block |
523-
should -BeLike *Write-Regex*
523+
should -BeLike *New-RegEx*
524524
}
525525

526526
context '-Between' {
527527
it 'Makes it easy to match double quotes' {
528-
Write-RegEx -Between '"' -Name InQuotes |
528+
New-RegEx -Between '"' -Name InQuotes |
529529
Use-RegEx -Extract -Match 'this is not in quotes. "This Is \"". This is not in quotes' |
530530
Select-Object -ExpandProperty InQuotes |
531531
should -Be 'This Is \"'
532532
}
533533

534534
it 'Makes it easy to match single quotes' {
535-
Write-RegEx -Between "'" -Name InQuotes -EscapeSequence "''" |
535+
New-RegEx -Between "'" -Name InQuotes -EscapeSequence "''" |
536536
Use-RegEx -Extract -Match "this is not in quotes. 'This Is '''. This is not in quotes" |
537537
Select-Object -ExpandProperty InQuotes |
538538
should -Be "This Is ''"
539539
}
540540

541541
it 'Makes it easy to match block comments' {
542-
Write-RegEx -Name BlockComment -Between '\<\#', '\#\>' -EscapeSequence '' |
542+
New-RegEx -Name BlockComment -Between '\<\#', '\#\>' -EscapeSequence '' |
543543
Use-RegEx -Extract -Match @'
544544
1 <#BlockComment#>
545545
2
@@ -551,17 +551,17 @@ describe Write-Regex {
551551
}
552552

553553
it 'Can Match a series of Digits up to a -DigitMax' {
554-
$r = Write-RegEx -DigitMax 16 -StartAnchor '^' -NotBefore '\d'
554+
$r = New-RegEx -DigitMax 16 -StartAnchor '^' -NotBefore '\d'
555555
$r.Match("16").Success | Should -Be $true
556556
$r.Match("17").Success | Should -Be $false
557557
}
558558

559559
it 'Can refer to a capture generator (parameters can -Be passed with () or {})' {
560-
Write-RegEx -Pattern '?<BalancedCode>{(}' |
560+
New-RegEx -Pattern '?<BalancedCode>{(}' |
561561
Use-RegEx -IsMatch -Match '({}' |
562562
should -Be $false
563563

564-
Write-RegEx -Pattern '?<BalancedCode>({)' |
564+
New-RegEx -Pattern '?<BalancedCode>({)' |
565565
Use-RegEx -IsMatch -Match '({}' |
566566
should -Be $true
567567
}
@@ -737,7 +737,7 @@ describe 'Generators' {
737737
should -BeLike '<#*#>'
738738
}
739739
it 'Will extract comments from a function' {
740-
Get-Command Write-Regex |
740+
Get-Command New-RegEx |
741741
?<MultilineComment> -Count 1 |
742742
should -BeLike '<#*#>'
743743
}
@@ -767,11 +767,11 @@ describe Set-Regex {
767767
(?<MathSymbol>\p{Sm})' -Description 'Using the special character class math' -Temporary
768768

769769

770-
Write-RegEx '?<MathSymbol>' | should -BeLike '*\p{Sm}*'
770+
New-RegEx '?<MathSymbol>' | should -BeLike '*\p{Sm}*'
771771
}
772772

773-
it 'Can accept the output of Write-Regex' {
774-
Write-RegEx -LiteralCharacter := -Name ColonOrEquals |
773+
it 'Can accept the output of New-RegEx' {
774+
New-RegEx -LiteralCharacter := -Name ColonOrEquals |
775775
Set-Regex
776776
Get-Module Irregular |
777777
Split-Path |

0 commit comments

Comments
 (0)