-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Brundage
committed
Apr 13, 2023
1 parent
b2c9874
commit c8c0419
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' | ||
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path | ||
|
||
New-RegEx -Description "Matching degrees" | | ||
New-Regex -Pattern ?<Decimals> | | ||
New-RegEx -CharacterClass Whitespace -Min 0 -Comment "Optional Whitespace" | | ||
New-RegEx -Atomic -Or @("Degrees","Degree", "°") -Comment "Degree(s) or the degree symbol" | | ||
New-RegEx -CharacterClass Whitespace -Min 0 -Comment "Optional Whitespace" | | ||
New-RegEx -Name UnitType -Optional -Pattern $( | ||
New-RegEx -Atomic -Or @( | ||
"Celsius" | ||
"C" | ||
"Fahrenheit" | ||
"F" | ||
) | ||
) -Comment "Optional unit" | | ||
Set-Content -Path (Join-Path $myRoot $myName) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Matching degrees | ||
(?<Decimals> | ||
(?<IsNegative>\-)? # It might be start with a - | ||
(?:(?> # Then it can be either: | ||
(?<Characteristic>\d+) # One or more digits (the Characteristic) | ||
(?:\.(?<Mantissa>\d+)){0,1} # followed by a period and one or more digits (the Mantissa) | ||
| # Or it can be | ||
(?:\.(?<Mantissa>\d+)) # just a Mantissa | ||
)) | ||
(?: | ||
E | ||
(?<Exponent> | ||
[+-]\d+ | ||
) | ||
)? | ||
) | ||
\s{0,} # Optional Whitespace | ||
(?> | ||
Degrees | | ||
Degree | | ||
°) # Degree(s) or the degree symbol | ||
(?<UnitType>(?> | ||
Celius | | ||
C | | ||
Fahrenheit | | ||
F))? # Optional unit | ||
|