├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── request-regex.md └── workflows │ ├── IrregularTests.yml │ └── OnIssue.yml ├── Build ├── GitHub │ ├── Actions │ │ └── Irregular.ps1 │ ├── Jobs │ │ ├── BuildIrregular.psd1 │ │ ├── RunGitPub.psd1 │ │ └── UseIrregularAction.psd1 │ └── Steps │ │ └── UseIrregularAction.psd1 ├── Irregular.ADOPipeline.PSDevOps.ps1 ├── Irregular.GitHubAction.PSDevops.ps1 ├── Irregular.GitHubWorkflow.PSDevops.ps1 ├── Irregular.HelpOut.ps1 ├── Irregular.PSSVG.ps1 └── Irregular.ezformat.ps1 ├── CHANGELOG.md ├── Commands ├── Compress-RegEx.ps1 ├── Export-RegEx.ps1 ├── Get-RegEx.ps1 ├── Import-RegEx.ps1 ├── New-RegEx.ps1 ├── Remove-RegEx.ps1 ├── Set-RegEx.ps1 ├── Show-RegEx.ps1 └── Use-RegEx.ps1 ├── Dockerfile ├── Irregular.format.ps1xml ├── Irregular.ps.psm1 ├── Irregular.psd1 ├── Irregular.psm1 ├── Irregular.tests.ps1 ├── Irregular.types.ps1xml ├── LICENSE ├── README.md ├── README.ps1.md ├── RegEx ├── ArithmeticOperator.regex.txt ├── BalancedBrackets.regex.txt ├── BalancedCode.regex.ps1 ├── BalancedCurlyBracket.regex.txt ├── BalancedParenthesis.regex.txt ├── C │ ├── Define.regex.source.ps1 │ ├── Define.regex.txt │ ├── Enum.regex.source.ps1 │ ├── Enum.regex.txt │ ├── IfDef.regex.source.ps1 │ ├── IfDef.regex.txt │ ├── Include.regex.source.ps1 │ ├── Include.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Struct.regex.source.ps1 │ └── Struct.regex.txt ├── CNC │ ├── GCode.regex.source.ps1 │ ├── GCode.regex.txt │ ├── README.md │ └── README.ps1.md ├── CSharp │ ├── Class.regex.source.ps1 │ ├── Class.regex.txt │ ├── Identifier.regex.source.ps1 │ ├── Identifier.regex.txt │ ├── Namespace.regex.source.ps1 │ ├── Namespace.regex.txt │ ├── README.md │ ├── README.ps1.md │ └── Using.regex.txt ├── CamelCaseSpace.regex.source.ps1 ├── CamelCaseSpace.regex.txt ├── Code │ ├── BuildVersion.regex.txt │ ├── Method.regex.source.ps1 │ ├── Method.regex.txt │ ├── Namespace.regex.txt │ ├── PackageVersion.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Region.regex.ps1 │ └── SemanticVersion.regex.txt ├── Colon.regex.txt ├── Console │ ├── 24BitColor.regex.source.ps1 │ ├── 24BitColor.regex.txt │ ├── 4BitColor.regex.source.ps1 │ ├── 4BitColor.regex.txt │ ├── 8BitColor.regex.source.ps1 │ ├── 8BitColor.regex.txt │ ├── Blink.regex.source.ps1 │ ├── Blink.regex.txt │ ├── Bold.regex.source.ps1 │ ├── Bold.regex.txt │ ├── Code.regex.source.ps1 │ ├── Code.regex.txt │ ├── Color.regex.source.ps1 │ ├── Color.regex.txt │ ├── Console.tests.ps1 │ ├── Cursor.regex.source.ps1 │ ├── Cursor.regex.txt │ ├── DefaultColor.regex.source.ps1 │ ├── DefaultColor.regex.txt │ ├── Faint.regex.source.ps1 │ ├── Faint.regex.txt │ ├── Hide.regex.source.ps1 │ ├── Hide.regex.txt │ ├── Invert.regex.source.ps1 │ ├── Invert.regex.txt │ ├── Italic.regex.source.ps1 │ ├── Italic.regex.txt │ ├── Link.regex.source.ps1 │ ├── Link.regex.txt │ ├── Note.regex.source.ps1 │ ├── Note.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Reset.regex.source.ps1 │ ├── Reset.regex.txt │ ├── Strikethrough.regex.source.ps1 │ ├── Strikethrough.regex.txt │ ├── Style.regex.source.ps1 │ ├── Style.regex.txt │ ├── Underline.regex.source.ps1 │ └── Underline.regex.txt ├── Decimals.regex.txt ├── Degrees.regex.source.ps1 ├── Digits.regex.txt ├── DoubleQuotedString.regex.ps1 ├── EmailAddress.regex.source.ps1 ├── EmailAddress.regex.txt ├── Equals.regex.txt ├── FFmpeg │ ├── Configuration.regex.source.ps1 │ ├── Configuration.regex.txt │ ├── Input.regex.source.ps1 │ ├── Input.regex.txt │ ├── Metadata.regex.source.ps1 │ ├── Metadata.regex.txt │ ├── Output.regex.source.ps1 │ ├── Output.regex.txt │ ├── Progress.regex.source.ps1 │ ├── Progress.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Stream.regex.source.ps1 │ └── Stream.regex.txt ├── GenericBalancingExpression.regex.txt ├── GetMarkupTag.regex.ps1 ├── Git │ ├── Commit.regex.source.ps1 │ ├── Commit.regex.txt │ ├── Diff.regex.source.ps1 │ ├── Diff.regex.txt │ ├── DiffHeader.regex.source.ps1 │ ├── DiffHeader.regex.txt │ ├── DiffRange.regex.source.ps1 │ ├── DiffRange.regex.txt │ ├── Log.regex.source.ps1 │ ├── Log.regex.txt │ ├── README.md │ └── README.ps1.md ├── HTML │ ├── DataAttribute.regex.txt │ ├── DataSet.regex.txt │ ├── EndTag.regex.ps1 │ ├── IDAttribute.regex.txt │ ├── ItemScope.regex.txt │ ├── LinkedData.regex.source.ps1 │ ├── LinkedData.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── StartOrEndTag.regex.ps1 │ └── StartTag.regex.ps1 ├── HexColor.regex.input.txt ├── HexColor.regex.output.txt ├── HexColor.regex.source.ps1 ├── HexColor.regex.txt ├── HexDigits.regex.txt ├── JSON │ ├── List.regex.txt │ ├── ListItem.regex.ps1 │ ├── ListSeparator.regex.txt │ ├── Number.regex.txt │ ├── Property.regex.ps1 │ ├── PropertyName.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── String.regex.txt │ └── Value.regex.txt ├── Keyboard │ ├── Shortcut.regex.source.ps1 │ └── Shortcut.regex.txt ├── LeadingWhitespace.regex.txt ├── LineEndsWithColon.regex.txt ├── LineStartOrEnd.regex.txt ├── Liquid │ ├── Expression.regex.source.ps1 │ ├── Expression.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Tag.regex.source.ps1 │ └── Tag.regex.txt ├── Markdown │ ├── CodeBlock.regex.ps1 │ ├── Heading.regex.ps1 │ ├── Link.regex.ps1 │ ├── List.regex.source.ps1 │ ├── List.regex.txt │ ├── Markdown.regex.tests.ps1 │ ├── README.md │ ├── README.ps1.md │ ├── ThematicBreak.regex.txt │ ├── YAMLHeader.regex.source.ps1 │ └── YAMLHeader.regex.txt ├── MultilineComment.regex.ps1 ├── Mustache │ ├── README.md │ ├── README.ps1.md │ └── Tag.regex.ps1 ├── Network │ ├── IPv4Address.regex.input.txt │ ├── IPv4Address.regex.output.txt │ ├── IPv4Address.regex.source.ps1 │ ├── IPv4Address.regex.txt │ ├── MACAddress.regex.source.ps1 │ ├── MACAddress.regex.txt │ ├── README.md │ └── README.ps1.md ├── NewLine.regex.txt ├── NextColon.regex.txt ├── NextWord.regex.txt ├── NumberAndExponent.regex.txt ├── NumberSign.regex.txt ├── OpenSCAD │ ├── Customization.regex.source.ps1 │ ├── Customization.regex.txt │ ├── Function.regex.source.ps1 │ ├── Function.regex.txt │ ├── Include.regex.source.ps1 │ ├── Include.regex.txt │ ├── Module.regex.source.ps1 │ ├── Module.regex.txt │ ├── Parameter.regex.source.ps1 │ ├── Parameter.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── Use.regex.source.ps1 │ └── Use.regex.txt ├── OptionalWhitespace.regex.txt ├── PHP │ └── Tag.regex.txt ├── PII │ ├── README.md │ ├── README.ps1.md │ ├── Redacted_SSN.regex.input.txt │ ├── Redacted_SSN.regex.source.ps1 │ ├── Redacted_SSN.regex.txt │ ├── Unredacted_SSN.regex.input.txt │ ├── Unredacted_SSN.regex.source.ps1 │ └── Unredacted_SSN.regex.txt ├── PowerShell │ ├── Attribute.regex.txt │ ├── AttributeValue.regex.txt │ ├── Function.regex.txt │ ├── Hashtable.regex.source.ps1 │ ├── Hashtable.regex.txt │ ├── HelpField.regex.ps1 │ ├── Invoke_Variable.regex.source.ps1 │ ├── Invoke_Variable.regex.txt │ ├── ParameterSet.regex.source.ps1 │ ├── ParameterSet.regex.txt │ ├── PowerShell.regex.tests.ps1 │ ├── README.md │ ├── README.ps1.md │ ├── Region.regex.ps1 │ ├── Requires.regex.source.ps1 │ ├── Requires.regex.txt │ ├── ScriptBlock.regex.txt │ ├── Variable.regex.input.txt │ ├── Variable.regex.output.txt │ ├── Variable.regex.source.ps1 │ └── Variable.regex.txt ├── Punctuation.regex.txt ├── README.md ├── REST │ └── Variable.regex.ps1 ├── RegularExpression │ ├── Group.regex.txt │ ├── GroupName.regex.source.ps1 │ ├── GroupName.regex.txt │ ├── Quantifier.regex.input.txt │ ├── Quantifier.regex.output.txt │ ├── Quantifier.regex.source.ps1 │ ├── Quantifier.regex.txt │ ├── README.md │ └── README.ps1.md ├── Security │ ├── AccessToken.regex.ps1 │ ├── JWT.regex.source.ps1 │ ├── JWT.regex.txt │ └── README.md ├── SingleQuotedString.regex.ps1 ├── StartsWithCapture.regex.txt ├── Subtitle │ ├── README.md │ ├── README.ps1.md │ ├── SRT.regex.source.ps1 │ ├── SRT.regex.txt │ ├── VTT.regex.source.ps1 │ └── VTT.regex.txt ├── Symbol.regex.source.ps1 ├── Symbol.regex.txt ├── Symbol │ ├── Currency.regex.source.ps1 │ ├── Currency.regex.txt │ ├── Math.regex.source.ps1 │ └── Math.regex.txt ├── Tag.regex.txt ├── TrueOrFalse.regex.txt ├── Unix │ ├── Conf_File.regex.source.ps1 │ ├── Conf_File.regex.txt │ ├── Conf_Line.regex.source.ps1 │ ├── Conf_Line.regex.txt │ ├── Conf_Section.regex.source.ps1 │ ├── Conf_Section.regex.txt │ ├── Cron_Interval.regex.source.ps1 │ ├── Cron_Interval.regex.txt │ ├── Duration.regex.source.ps1 │ ├── Duration.regex.txt │ ├── FileSystemType.regex.source.ps1 │ ├── FileSystemType.regex.txt │ ├── Mount.regex.input.txt │ ├── Mount.regex.source.ps1 │ ├── Mount.regex.txt │ ├── README.md │ ├── README.ps1.md │ ├── User.regex.input.txt │ ├── User.regex.source.ps1 │ └── User.regex.txt └── YAML │ ├── Key.regex.ps1 │ └── Value.regex.ps1 ├── RegExQuickReference.md ├── SavedPatterns.md ├── Types ├── Irregular.Match.Extract │ ├── .get_EndIndex.ps1 │ ├── .get_Input.ps1 │ └── .get_StartIndex.ps1 ├── Irregular.Regex.Output.format.ps1 ├── Irregular.Regex.format.ps1 ├── Irregular.Regular.Expression.format.ps1 ├── Irregular.Regular.Expression │ ├── get_GroupNames.ps1 │ ├── get_IsValid.ps1 │ └── get_Pattern.ps1 ├── Match │ ├── Peek.ps1 │ ├── System.Text.RegularExpressions.Match.format.ps1 │ ├── TypeName.txt │ ├── get_After.ps1 │ ├── get_Before.ps1 │ ├── get_Column.ps1 │ ├── get_EndIndex.ps1 │ ├── get_Input.ps1 │ ├── get_LastGroup.ps1 │ ├── get_Line.ps1 │ └── get_StartIndex.ps1 └── System.Text.RegularExpressions.RegEx.format.ps1 ├── UpdateSavedPatterns.md.irregular.ps1 ├── action.yml ├── assets ├── Irregular.svg ├── Irregular_600_Square.png ├── Irregular_85x85.png ├── Irregular_Wide.png ├── README.md ├── RegexSyntaxHighlighting.gif └── RegexSyntaxHighlighting2.gif ├── azure-pipelines.yml ├── docs ├── 2021-10-24.md ├── 2021-10.md ├── 2021-11-07.md ├── 2021-11-18.md ├── 2021-11-22.md ├── 2021-11-29.md ├── 2021-11.md ├── 2021-12-28.md ├── 2021-12.md ├── 2021.md ├── 2022-01-09.md ├── 2022-01.md ├── 2022-08-09.md ├── 2022-08.md ├── 2022-09-06.md ├── 2022-09-12.md ├── 2022-09-18.md ├── 2022-09-22.md ├── 2022-09-29.md ├── 2022-09.md ├── 2022-10-01.md ├── 2022-10-16.md ├── 2022-10-29.md ├── 2022-10.md ├── 2022-12-15.md ├── 2022-12.md ├── 2022.md ├── 2023-07-20.md ├── 2023-07.md ├── 2023.md ├── 2024-04-16.md ├── 2024-04.md ├── 2024.md ├── CHANGELOG.md ├── CNAME ├── Compress-Regex.md ├── Export-RegEx.md ├── Get-RegEx.md ├── Import-RegEx.md ├── New-RegEx.md ├── README.md ├── RegExQuickReference.md ├── Regular_Expression_Quick_Reference.md ├── Remove-RegEx.md ├── SavedPatterns.md ├── Set-RegEx.md ├── Show-RegEx.md ├── Understanding_Regular_Expressions.md ├── Use-RegEx.md ├── Using_Regular_Expressions_In_PowerShell.walkthru.md ├── _config.yml ├── _posts │ ├── 2021-10-24-Irregular-v0.6.1.md │ ├── 2021-10-24-Irregular-v0.6.md │ ├── 2021-11-07-Irregular-v0.6.2.md │ ├── 2021-11-18-Irregular-v0.6.3.md │ ├── 2021-11-22-Irregular-v0.6.4.md │ ├── 2021-11-29-Irregular-v0.6.5.md │ ├── 2021-12-28-Irregular-0.6.6.md │ ├── 2022-01-09-Irregular-0.6.7.md │ ├── 2022-08-09-Irregular-0.6.8.md │ ├── 2022-09-06-Irregular-0.6.9.md │ ├── 2022-09-12-Irregular-0.7.0.md │ ├── 2022-09-18-Irregular-0.7.1.md │ ├── 2022-09-22-Irregular-0.7.2.md │ ├── 2022-09-29-Irregular-0.7.3.md │ ├── 2022-10-01-Irregular-0.7.4.md │ ├── 2022-10-16-Irregular-0.7.5.md │ ├── 2022-10-29-Irregular-0.7.6.md │ ├── 2022-12-15-Irregular-0.7.7.md │ ├── 2023-07-20-Irregular-0.7.8.md │ └── 2024-04-16-Irregular-0.7.9.md ├── assets │ ├── Irregular.svg │ ├── Irregular_600_Square.png │ ├── Irregular_85x85.png │ ├── Irregular_Wide.png │ ├── RegexSyntaxHighlighting.gif │ └── RegexSyntaxHighlighting2.gif └── rss.xml └── en-us ├── Regular_Expression_Quick_Reference.help.txt ├── Understanding_Regular_Expressions.help.txt ├── Using_Regular_Expressions_In_PowerShell.walkthru.help.txt └── about_Irregular.help.txt /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [StartAutomating] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | **To Reproduce** 15 | 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Actual behavior** 26 | A clear and concise description of what actually happens.. 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | **Additional context** 23 | 24 | Add any other context or screenshots about the feature request here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/request-regex.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Request RegEx 3 | about: Want a RegEx but don't want to write one? 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the Desired Expression** 11 | 12 | **Provide some Sample Source Text** 13 | 14 | **Highlight What you'd like to match** 15 | 16 | What parts of the samples should match? Which pieces of data are important to extract from the match? 17 | -------------------------------------------------------------------------------- /.github/workflows/OnIssue.yml: -------------------------------------------------------------------------------- 1 | 2 | name: OnIssueChanged 3 | on: 4 | issues: 5 | workflow_dispatch: 6 | jobs: 7 | RunGitPub: 8 | runs-on: ubuntu-latest 9 | if: ${{ success() }} 10 | steps: 11 | - name: Check out repository 12 | uses: actions/checkout@v2 13 | - name: Use GitPub Action 14 | uses: StartAutomating/GitPub@main 15 | id: GitPub 16 | with: 17 | TargetBranch: edits-$([DateTime]::Now.ToString("r").Replace(":","-").Replace(" ", "")) 18 | CommitMessage: Posting with GitPub [skip ci] 19 | PublishParameters: | 20 | { 21 | "Get-GitPubIssue": { 22 | "Repository": '${{github.repository}}', 23 | }, 24 | "Get-GitPubRelease": { 25 | "Repository": '${{github.repository}}', 26 | }, 27 | "Publish-GitPubJekyll": { 28 | "OutputPath": "docs/_posts" 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Build/GitHub/Jobs/RunGitPub.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | "runs-on" = "ubuntu-latest" 3 | if = '${{ success() }}' 4 | steps = @( 5 | @{ 6 | name = 'Check out repository' 7 | uses = 'actions/checkout@v2' 8 | } 9 | @{ 10 | name = 'Use GitPub Action' 11 | uses = 'StartAutomating/GitPub@main' 12 | id = 'GitPub' 13 | with = @{ 14 | TargetBranch = 'edits-$([DateTime]::Now.ToString("r").Replace(":","-").Replace(" ", ""))' 15 | CommitMessage = 'Posting with GitPub [skip ci]' 16 | PublishParameters = @' 17 | { 18 | "Get-GitPubIssue": { 19 | "Repository": '${{github.repository}}', 20 | }, 21 | "Get-GitPubRelease": { 22 | "Repository": '${{github.repository}}', 23 | }, 24 | "Publish-GitPubJekyll": { 25 | "OutputPath": "docs/_posts" 26 | } 27 | } 28 | '@ 29 | } 30 | } 31 | ) 32 | } -------------------------------------------------------------------------------- /Build/GitHub/Jobs/UseIrregularAction.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | "runs-on" = "ubuntu-latest" 3 | steps = @('Checkout','UseIrregularAction') 4 | } 5 | -------------------------------------------------------------------------------- /Build/GitHub/Steps/UseIrregularAction.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | name = 'Use Irregular Action' 3 | uses = 'StartAutomating/Irregular@master' 4 | id = 'Irregular' 5 | } 6 | 7 | 8 | -------------------------------------------------------------------------------- /Build/Irregular.ADOPipeline.PSDevOps.ps1: -------------------------------------------------------------------------------- 1 | #requires -Modules PSDevOps 2 | 3 | Push-Location ($PSScriptRoot | Split-Path) 4 | 5 | New-ADOPipeline -Stage PowerShellStaticAnalysis, TestPowerShellCrossPlatform, UpdatePowerShellGallery | 6 | Set-Content .\azure-pipelines.yml -Encoding UTF8 7 | 8 | Pop-Location -------------------------------------------------------------------------------- /Build/Irregular.GitHubAction.PSDevops.ps1: -------------------------------------------------------------------------------- 1 | #requires -Module Irregular 2 | #requires -Module PSDevOps 3 | 4 | Import-BuildStep -SourcePath ( 5 | Join-Path $PSScriptRoot 'GitHub' 6 | ) -BuildSystem GitHubAction 7 | 8 | Push-Location ($PSScriptRoot | Split-Path) 9 | 10 | New-GitHubAction -Name "UseIrregular" -Description 'Regular Expressions Made Strangle Simple' -Action Irregular -Icon cpu -OutputPath .\action.yml 11 | 12 | Pop-Location -------------------------------------------------------------------------------- /Build/Irregular.GitHubWorkflow.PSDevops.ps1: -------------------------------------------------------------------------------- 1 | #requires -Module PSDevOps 2 | Push-Location ($PSScriptRoot | Split-Path) 3 | 4 | Import-BuildStep -SourcePath ( 5 | Join-Path $PSScriptRoot 'GitHub' 6 | ) -BuildSystem GitHubWorkflow 7 | 8 | 9 | New-GitHubWorkflow -Name "Test, Tag, Release, and Publish" -Job PowerShellStaticAnalysis, 10 | TestPowerShellOnLinux, 11 | TagReleaseAndPublish, 12 | BuildIrregular -On Push, Demand -Environment ([Ordered]@{ 13 | REGISTRY = 'ghcr.io' 14 | IMAGE_NAME = '${{ github.repository }}' 15 | }) -OutputPath .\.github\workflows\IrregularTests.yml 16 | 17 | New-GitHubWorkflow -Name "Run GitHub Action" -On Push, 18 | Demand -Job UseIrregularAction -OutputPath .\.github\workflows\RunIrregularAction.yml 19 | 20 | New-GitHubWorkflow -On Demand -Job RunGitPub -Name "GitPub" -OutputPath .\.github\workflows\RunGitPub.yml 21 | 22 | 23 | Pop-Location -------------------------------------------------------------------------------- /Build/Irregular.HelpOut.ps1: -------------------------------------------------------------------------------- 1 | Push-Location ($PSScriptRoot | Split-Path) 2 | 3 | $IrregularLoaded = Get-Module Irregular 4 | if (-not $IrregularLoaded) { 5 | $IrregularLoaded = Get-ChildItem -Recurse -Filter "*.psd1" | 6 | Where-Object Name -eq 'Irregular.psd1' | 7 | Import-Module -Name { $_.FullName } -Force -PassThru 8 | } 9 | if ($IrregularLoaded) { 10 | "::notice title=ModuleLoaded::Irregular Loaded" | Out-Host 11 | } else { 12 | "::error:: Irregular not loaded" |Out-Host 13 | } 14 | if ($IrregularLoaded) { 15 | Save-MarkdownHelp -Module $IrregularLoaded.Name -PassThru -SkipCommandType Alias 16 | } 17 | 18 | Pop-Location -------------------------------------------------------------------------------- /Build/Irregular.PSSVG.ps1: -------------------------------------------------------------------------------- 1 | #requires -Module PSSVG 2 | 3 | 4 | Push-Location ($PSScriptRoot | Split-Path) 5 | 6 | $psChevron = 7 | = -Id psChevron -Content @( 8 | = -Points (@( 9 | "40,20" 10 | "45,20" 11 | "60,50" 12 | "35,80" 13 | "32.5,80" 14 | "55,50" 15 | ) -join ' ') 16 | ) -ViewBox 100, 100 -PreserveAspectRatio $false 17 | 18 | 19 | $assetsPath = Join-Path $pwd assets 20 | 21 | = -ViewBox 300, 100 @( 22 | $psChevron 23 | 24 | = -Href '#psChevron' -Fill '#4488ff' -X 7.5% -Y 0% -Width 15% 25 | = -X 50% -Y 50% -TextAnchor 'middle' -DominantBaseline 'middle' -Content @( 26 | = -Content "?<" -Rotate .5 -Dy .1em 27 | = -Content 'Irregular' -Rotate -1 -Dx -.25em -Dy -.1em 28 | = -Content '>' -Rotate .5 -Dx -.25em -Dy .1em 29 | ) -FontFamily 'sans-serif' -Fill '#4488ff' -FontSize 36 30 | ) -OutputPath (Join-Path $assetsPath Irregular.svg) 31 | 32 | 33 | Pop-Location -------------------------------------------------------------------------------- /Build/Irregular.ezformat.ps1: -------------------------------------------------------------------------------- 1 | #requires -Module EZOut 2 | # Install-Module EZOut or https://github.com/StartAutomating/EZOut 3 | $myFile = $MyInvocation.MyCommand.ScriptBlock.File 4 | $myModuleName = 'Irregular' 5 | $myRoot = $myFile | Split-Path | Split-Path 6 | Push-Location $myRoot 7 | $formatting = @( 8 | # Add your own Write-FormatView here, 9 | # or put them in a Formatting or Views directory 10 | foreach ($potentialDirectory in 'Formatting','Views', 'Types') { 11 | Join-Path $myRoot $potentialDirectory | 12 | Get-ChildItem -ea ignore | 13 | Import-FormatView -FilePath {$_.Fullname} 14 | } 15 | ) 16 | 17 | $destinationRoot = $myRoot 18 | 19 | if ($formatting) { 20 | $myFormatFile = Join-Path $destinationRoot "$myModuleName.format.ps1xml" 21 | $formatting | Out-FormatData -Module $MyModuleName | Set-Content $myFormatFile -Encoding UTF8 22 | Get-Item $myFormatFile 23 | } 24 | 25 | $types = @( 26 | # Add your own Write-TypeView statements here 27 | # or declare them in the 'Types' directory 28 | Join-Path $myRoot Types | 29 | Get-Item -ea ignore | 30 | Import-TypeView 31 | 32 | ) 33 | 34 | if ($types) { 35 | $myTypesFile = Join-Path $destinationRoot "$myModuleName.types.ps1xml" 36 | $types | Out-TypeData | Set-Content $myTypesFile -Encoding UTF8 37 | Get-Item $myTypesFile 38 | } 39 | Pop-Location 40 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/powershell 2 | ARG ModuleName=Irregular 3 | COPY . ./usr/local/share/powershell/Modules/$ModuleName 4 | RUN pwsh -c "New-Item -Path /root/.config/powershell/Microsoft.PowerShell_profile.ps1 -Value 'Import-Module $ModuleName' -Force" 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 James Brundage 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RegEx/ArithmeticOperator.regex.txt: -------------------------------------------------------------------------------- 1 | # Simple Arithmetic Operators 2 | [+-/÷*×] 3 | -------------------------------------------------------------------------------- /RegEx/BalancedBrackets.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches content in brackets, as long as it is balanced 2 | \[ # An open bracket 3 | (?> # Followed by... 4 | [^\[\]]+| # any number of non-bracket character OR 5 | \[(?)| # an open bracket (in which case increment depth) OR 6 | \](?<-Depth>) # a closed bracket (in which case decrement depth) 7 | )*(?(Depth)(?!)) # until depth is 0. 8 | \] # followed by a closing bracket -------------------------------------------------------------------------------- /RegEx/BalancedCode.regex.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Matches Balanced Code 4 | .Description 5 | Matches code balanced by a [, {, or ( 6 | #> 7 | param( 8 | [ValidateSet('[','{', '(')] 9 | $Open = '{' 10 | ) 11 | 12 | $comment = 13 | if ($open -eq '[') { 'bracket' } 14 | elseif ($open -eq '{') { 'brace' } 15 | elseif ($Open -eq '(') { 'parenthesis' } 16 | 17 | $close = 18 | if ($Open -eq '[') { ']' } 19 | elseif ($Open -eq '{') { '}' } 20 | elseif ($Open -eq '(') { ')' } 21 | # Matches content in brackets, as long as it is balanced 22 | @" 23 | \$open # An open $comment 24 | (?> # Followed by... 25 | [^\$open\$close]+| # any number of non-$comment character OR 26 | \$open(?)| # an open $comment (in which case increment depth) OR 27 | \$close(?<-Depth>) # a closed $comment (in which case decrement depth) 28 | )*(?(Depth)(?!)) # until depth is 0. 29 | \$close # followed by a closing $comment 30 | "@ -------------------------------------------------------------------------------- /RegEx/BalancedCurlyBracket.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches content in {}, as long as it is balanced 2 | \{ # An open { 3 | (?> # Followed by... 4 | [^\{\}]+| # any number of non-bracket character OR 5 | \{(?)| # an open curly bracket (in which case increment depth) OR 6 | \}(?<-Depth>) # a closed curly bracket (in which case decrement depth) 7 | )*?(?(Depth)(?!)) # until depth is 0. 8 | \} # followed by a } -------------------------------------------------------------------------------- /RegEx/BalancedParenthesis.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches content in parenthesis, as long as it is balanced 2 | \( # An open parenthesis 3 | (?> # Followed by... 4 | [^\(\)]+| # any number of non-parenthesis character OR 5 | \((?)| # an open parenthesis (in which case increment depth) OR 6 | \)(?<-Depth>) # a closed parenthesis (in which case decrement depth) 7 | )*(?(Depth)(?!)) # until depth is 0. 8 | \) # followed by a closing parenthesis -------------------------------------------------------------------------------- /RegEx/C/Define.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description @' 4 | Matches C/C++ #define 5 | '@ -Pattern "\#\s{0,} 6 | define" -Comment " Match the define" -Modifier Multiline| 7 | Write-RegEx -CharacterClass Whitespace -Repeat -Comment "Whitespace" | 8 | Write-RegEx -Name Identifier -CharacterClass Word -Repeat -Comment "The identifier" | 9 | Write-RegEx -CharacterClass Whitespace -Min 0 -Comment "Optional Whitespace"| 10 | Write-RegEx -Atomic -Name Definition -Or @( 11 | Write-RegEx '[^\\]' -Repeat -EndAnchor LineEnd -Comment "A Line with no escape OR" 12 | Write-RegEx -Min 1 ( 13 | Write-RegEx -Name Line -Pattern '[^\\]+?\\' -Before '(?>\r\n|\n)' -Comment "One or more lines ending with \" 14 | ) 15 | ) -Description "Then either" |#> 16 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 17 | 18 | -------------------------------------------------------------------------------- /RegEx/C/Define.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches C/C++ #define 2 | (?m)\#\s{0,} 3 | define # Match the define 4 | \s+ # Whitespace 5 | (?\w+) # The identifier 6 | \s{0,} # Optional Whitespace 7 | # Then either 8 | (?>(?([^\\]+$ # A Line with no escape OR 9 | |(?[^\\]+?\\(?=(?>\r\n|\n))) # One or more lines ending with \ 10 | {1,}))) 11 | -------------------------------------------------------------------------------- /RegEx/C/Enum.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches a C/C++ Enum" -Modifier IgnoreCase -Not | 5 | New-RegEx -Pattern 'enum' -Comment 'Starts with a literal enum' | 6 | New-RegEx -CharacterClass Whitespace -Min 1 -Comment 'Followed by whitespace' | 7 | New-RegEx -Name Identifier -Pattern ( 8 | New-RegEx -Pattern '[_a-zA-Z]' | 9 | New-RegEx -Pattern '[_a-zA-Z0-9]' -Min 1 10 | ) -Comment 'Followed by an identifier' | 11 | New-RegEx -CharacterClass Whitespace, NewLine, CarriageReturn -Min 0 -Comment 'Followed by optional whitespace' | 12 | New-RegEx -Name Comment -Pattern '//.+[\r\n]' -Optional -Comment 'Followed by an optional comment' | 13 | New-RegEx -CharacterClass Whitespace, NewLine,CarriageReturn -Min 0 -Comment 'Followed by optional whitespace' | 14 | New-RegEx -Name Values -Pattern '?' -Comment 'Followed by balanced curly braces' | 15 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru -------------------------------------------------------------------------------- /RegEx/C/Enum.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a C/C++ Enum 2 | (?-i)enum # Starts with a literal enum 3 | \s{1,} # Followed by whitespace 4 | (?[_a-zA-Z][_a-zA-Z0-9]{1,}) # Followed by an identifier 5 | [\s\n\r]{0,} # Followed by optional whitespace 6 | (?//.+[\r\n])? # Followed by an optional comment 7 | [\s\n\r]{0,} # Followed by optional whitespace 8 | (?(? 9 | \{ # An open { 10 | (?> # Followed by... 11 | [^\{\}]+| # any number of non-bracket character OR 12 | \{(?)| # an open curly bracket (in which case increment depth) OR 13 | \}(?<-Depth>) # a closed curly bracket (in which case decrement depth) 14 | )*?(?(Depth)(?!)) # until depth is 0. 15 | \} # followed by a } 16 | ) 17 | ) # Followed by balanced curly braces 18 | 19 | -------------------------------------------------------------------------------- /RegEx/C/IfDef.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches C/C++ #if/#ifdef/#ifndef .. #endif 2 | (?m)(?if[^\s]+) # Match (and the rest of the word) 4 | (?.+?$) # the is anything until the end of the line 5 | # Now things get tricky. Because ifdefs can nest, we need a balancing group 6 | (?> 7 | [^\#]+ # Any non-preprocessor character matches, and doesn't change the balance 8 | | 9 | (?) # An if Increases the 10 | | 11 | (?) # An EndIf Decreases the Depth 12 | | 13 | \# # Match any remaining 14 | )*(?(Depth)(?!)) # Match Until EndIf is balanced 15 | (?s' | 10 | Write-RegEx -CharacterClass Word -LiteralCharacter '.\/' -Repeat -Name Header | 11 | Write-RegEx -Pattern '\>' -Comment 'OR' 12 | 13 | Write-RegEx -LiteralCharacter '"' -Comment 'A Source File, enclosed in ""s' | 14 | Write-RegEx -CharacterClass Word -LiteralCharacter '.\/' -Repeat -Name SourceFile | 15 | Write-RegEx -LiteralCharacter '"') | 16 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 17 | 18 | -------------------------------------------------------------------------------- /RegEx/C/Include.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches C/C++ #include 2 | \#\s{0,} 3 | include # Match the include, followed by 4 | \s+(?>(?(\< # A header, enclosed in <>s 5 | (?
[\w\.\\\/]+)\> # OR 6 | |\" # A Source File, enclosed in ""s 7 | (?[\w\.\\\/]+)\"))) 8 | -------------------------------------------------------------------------------- /RegEx/C/README.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions to help parse C and C++ 2 | 3 | 4 | |Name |Description |IsGenerator| 5 | |---------------------------------|------------------------------------------|-----------| 6 | |[?](Define.regex.txt) |Matches C/C++ #define |False | 7 | |[?](Enum.regex.txt) |Matches a C/C++ Enum |False | 8 | |[?](IfDef.regex.txt) |Matches C/C++ #if/#ifdef/#ifndef .. #endif|False | 9 | |[?](Include.regex.txt)|Matches C/C++ #include |False | 10 | |[?](Struct.regex.txt) |Matches a C/C++ Struct |False | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /RegEx/C/README.ps1.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions to help parse C and C++ 2 | 3 | ~~~PipeScript{ 4 | Import-Module ../../Irregular.psd1 -Global 5 | $directoryName = $pwd | Split-Path -Leaf 6 | [PSCustomObject]@{ 7 | Table = Get-Regex -Name "${directoryName}_*" | 8 | Sort-Object Name | 9 | Select @{ 10 | Name='Name' 11 | Expression={"[?<$($_.Name)>]($($_.Path | Split-Path -Leaf))"} 12 | }, Description, IsGenerator 13 | }} 14 | ~~~ 15 | -------------------------------------------------------------------------------- /RegEx/C/Struct.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches a C/C++ Struct" -Modifier IgnoreCase -Not | 5 | New-RegEx -Pattern 'struct' -Comment 'Starts with a literal struct' | 6 | New-RegEx -CharacterClass Whitespace -Min 1 -Comment 'Followed by whitespace' | 7 | New-RegEx -Name Identifier -Pattern ( 8 | New-RegEx -Pattern '[_a-zA-Z]' | 9 | New-RegEx -Pattern '[_a-zA-Z0-9]' -Min 1 10 | ) -Comment 'Followed by an identifier' | 11 | New-RegEx -CharacterClass Whitespace, NewLine, CarriageReturn -Min 0 -Comment 'Followed by optional whitespace' | 12 | New-RegEx -Name Comment -Pattern '//.+[\r\n]' -Optional -Comment 'Followed by an optional comment' | 13 | New-RegEx -CharacterClass Whitespace, NewLine,CarriageReturn -Min 0 -Comment 'Followed by optional whitespace' | 14 | New-RegEx -Name Values -Pattern '?' -Comment 'Followed by balanced curly braces' | 15 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru -------------------------------------------------------------------------------- /RegEx/C/Struct.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a C/C++ Struct 2 | (?-i)struct # Starts with a literal struct 3 | \s{1,} # Followed by whitespace 4 | (?[_a-zA-Z][_a-zA-Z0-9]{1,}) # Followed by an identifier 5 | [\s\n\r]{0,} # Followed by optional whitespace 6 | (?//.+[\r\n])? # Followed by an optional comment 7 | [\s\n\r]{0,} # Followed by optional whitespace 8 | (?(? 9 | \{ # An open { 10 | (?> # Followed by... 11 | [^\{\}]+| # any number of non-bracket character OR 12 | \{(?)| # an open curly bracket (in which case increment depth) OR 13 | \}(?<-Depth>) # a closed curly bracket (in which case decrement depth) 14 | )*?(?(Depth)(?!)) # until depth is 0. 15 | \} # followed by a } 16 | ) 17 | ) # Followed by balanced curly braces 18 | 19 | -------------------------------------------------------------------------------- /RegEx/CNC/GCode.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches GCode Instructions 2 | (?-i)(?m)^\s{0,} # Optional Whitespace after any newline 3 | # Will match either a 4 | (?> 5 | \;(?(?:.|\s){0,}?(?=\z|[\r\n])) # Literal ;, followed by anything until the next newline 6 | ? | 7 | (?(?[\%A-Z])(?\d+)) # An instruction, consisting of a letter and one or more numbers 8 | (?(Instruction)((?:\s(?[^\;\s]+)){0,})) # Instructions may be followed by one or more arguments, separated by spaces 9 | [\s-[\r\n]]{0,} # Match any trailing whitespace 10 | (?:\;(?(?:.|\s){0,}?(?=\z|[\r\n])))? # Match any trailing comments 11 | ) 12 | -------------------------------------------------------------------------------- /RegEx/CNC/README.md: -------------------------------------------------------------------------------- 1 | This directory contains Regular Expressions for [Computer Numerical Control](https://en.wikipedia.org/wiki/Numerical_control) 2 | 3 | 4 | |Name |Description |Source | 5 | |-------------------------------|--------------------------|--------------------------------| 6 | |[?](GCode.regex.txt)|Matches GCode Instructions|[source](GCode.regex.source.ps1)| 7 | 8 | 9 | -------------------------------------------------------------------------------- /RegEx/CNC/README.ps1.md: -------------------------------------------------------------------------------- 1 | This directory contains Regular Expressions for [Computer Numerical Control](https://en.wikipedia.org/wiki/Numerical_control) 2 | 3 | ~~~PipeScript{ 4 | Import-Module ../../Irregular.psd1 -Global 5 | $directoryName = $pwd | Split-Path -Leaf 6 | [PSCustomObject]@{ 7 | Table = Get-Regex -Name "${directoryName}_*" | 8 | Sort-Object Name | 9 | .Name { 10 | "[?<$($_.Name)>]($($_.Path | Split-Path -Leaf))" 11 | } .Description .Source { 12 | if ($_.IsGenerator) { 13 | "[generator]($($_.Path | Split-Path -Leaf))" 14 | } 15 | else { 16 | $sourcePath = $_.Path -replace '\.txt$', '.source.ps1' 17 | if (Test-Path $sourcePath) { 18 | "[source]($($sourcePath | Split-Path -Leaf))" 19 | } else { 20 | '' 21 | } 22 | } 23 | } 24 | }} 25 | ~~~ -------------------------------------------------------------------------------- /RegEx/CSharp/Identifier.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | New-RegEx -Description 'Matches a CSharp identifier' | 4 | New-Regex -Comment "Must start with a letter or underscore" -LiteralCharacter _ -CharacterClass Letter | 5 | New-RegEx -CharacterClass PunctuationConnector, Letter, Digit, MarkNonSpacing -Description "Followed by any number of letters, digitis, nonspacing marks, and connector punctation" -Min 0| 6 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 7 | -------------------------------------------------------------------------------- /RegEx/CSharp/Identifier.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a CSharp identifier 2 | [\p{L}_] # Must start with a letter or underscore 3 | # Followed by any number of letters, digitis, nonspacing marks, and connector punctation 4 | [\p{Pc}\p{L}\d\p{Mn}]{0,} 5 | -------------------------------------------------------------------------------- /RegEx/CSharp/Namespace.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description 'Matches a CSharp namespace' -Pattern '?(CSharp)'| 4 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -------------------------------------------------------------------------------- /RegEx/CSharp/Namespace.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a CSharp namespace 2 | (? 3 | namespace # the keyword namespace FOLLOWED BY 4 | \s{1,} # at least one whitespace character FOLLOWED BY 5 | (?\S{1,}) # the NAME of the namespace is N-non-whitespace FOLLOWED BY 6 | \s{0,} # optional whitespace FOLLOWED BY 7 | (?\{ # the CONTENT starts with an opening bracket FOLLOWED BY 8 | (?> # an atomic group CONTAINING 9 | [^\{\}]+| # Anything that's not a bracket OR 10 | \{(?)|# if it's a bracket, increment depth OR 11 | \}(?<-Depth>)# if it's a closing bracket, decrement depth 12 | )* # 0 or more times 13 | (?(Depth) # IF depth is set 14 | (?!)) # this group isn't balanced, keep filling content 15 | \}) # until we run into a closing bracket 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /RegEx/CSharp/README.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions to help parse C# code. 2 | 3 | 4 | |Name |Description |Source | 5 | |--------------------------------------------|------------------------------|-------------------------------------| 6 | |[?](Class.regex.txt) |Matches a CSharp class |[source](Class.regex.source.ps1) | 7 | |[?](Identifier.regex.txt)|Matches a CSharp identifier |[source](Identifier.regex.source.ps1)| 8 | |[?](Namespace.regex.txt) |Matches a CSharp namespace |[source](Namespace.regex.source.ps1) | 9 | |[?](Using.regex.txt) |Matches a CSharp using keyword| 10 | 11 | 12 | -------------------------------------------------------------------------------- /RegEx/CSharp/README.ps1.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions to help parse C# code. 2 | 3 | ~~~PipeScript{ 4 | Import-Module ../../Irregular.psd1 -Global 5 | $directoryName = $pwd | Split-Path -Leaf 6 | [PSCustomObject]@{ 7 | Table = Get-Regex -Name "${directoryName}_*" | 8 | Sort-Object Name | 9 | .Name { 10 | "[?<$($_.Name)>]($($_.Path | Split-Path -Leaf))" 11 | } .Description .Source { 12 | if ($_.IsGenerator) { 13 | "[generator]($($_.Path | Split-Path -Leaf))" 14 | } 15 | else { 16 | $sourcePath = $_.Path -replace '\.txt$', '.source.ps1' 17 | if (Test-Path $sourcePath) { 18 | "[source]($($sourcePath | Split-Path -Leaf))" 19 | } else { 20 | '' 21 | } 22 | } 23 | } 24 | }} 25 | ~~~ -------------------------------------------------------------------------------- /RegEx/CSharp/Using.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a CSharp using keyword 2 | using # using statement 3 | \s{1,} # whitepsace 4 | (?[\.\w+]+) # a namespace 5 | \s{0,} # optional whitespace 6 | \; # a semicolon 7 | -------------------------------------------------------------------------------- /RegEx/CamelCaseSpace.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-Regex -Not -Modifier IgnoreCase -Description "Matches where a CamelCaseSpace would be" | 5 | New-RegEx -After '[a-z]' | 6 | New-RegEx -Before '[A-Z]' | 7 | Set-Content -Path (Join-Path $myRoot $myName) 8 | -------------------------------------------------------------------------------- /RegEx/CamelCaseSpace.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches where a CamelCaseSpace would be 2 | (?-i)(?<=[a-z])(?=[A-Z]) 3 | -------------------------------------------------------------------------------- /RegEx/Code/BuildVersion.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a build version 2 | (?!\p{P}) # Do not match if preceeded by punctuation 3 | (?\d+) # Match a major version 4 | \. # followed by a period 5 | (?\d+) # followed by a minor version 6 | (?:\.(?\d+))? # followed by an optional build number 7 | (?:\.(?\d+))? # followed by an optional build revision. -------------------------------------------------------------------------------- /RegEx/Code/Method.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches methods in most languages" | 5 | New-RegEx -After ( 6 | New-RegEx -CharacterClass Punctuation, Whitespace, Tab 7 | ) -Comment "Methods start after punctuation or whitespace" | 8 | New-RegEx -CharacterClass Word -LiteralCharacter _ -Repeat -Name MethodName -Comment "Method names can be any word character or undererscore" | 9 | New-RegEx -Description "A Generic Balancing Expression" -Name MethodParameters -Pattern '?' | 10 | Set-Content -Path (Join-Path $myRoot $myName) 11 | -------------------------------------------------------------------------------- /RegEx/Code/Method.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches methods in most languages 2 | (?<=[\p{P}\s\t]) # Methods start after punctuation or whitespace 3 | (?[\w_]+) # Method names can be any word character or undererscore 4 | # A Generic Balancing Expression 5 | (?(? 6 | \p{Ps} # The open punctuation 7 | (?> 8 | [^\p{Ps}\p{Pe}]+| # Anything that is neither open or closed punctuation 9 | \p{Ps}(?)| # If it's open punctuation, increment depth 10 | \p{Pe}(?<-Depth>) # If it's closed punctuation, decrement depth 11 | )*(?(Depth)(?!)) # Match until depth is empty 12 | \p{Pe} # The closing punctuation 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /RegEx/Code/Namespace.regex.txt: -------------------------------------------------------------------------------- 1 | # Finds a Namespace (captures the Name and the Content between {}) 2 | namespace # the keyword namespace FOLLOWED BY 3 | \s{1,} # at least one whitespace character FOLLOWED BY 4 | (?\S{1,}) # the NAME of the namespace is N-non-whitespace FOLLOWED BY 5 | \s{0,} # optional whitespace FOLLOWED BY 6 | (?\{ # the CONTENT starts with an opening bracket FOLLOWED BY 7 | (?> # an atomic group CONTAINING 8 | [^\{\}]+| # Anything that's not a bracket OR 9 | \{(?)|# if it's a bracket, increment depth OR 10 | \}(?<-Depth>)# if it's a closing bracket, decrement depth 11 | )* # 0 or more times 12 | (?(Depth) # IF depth is set 13 | (?!)) # this group isn't balanced, keep filling content 14 | \}) # until we run into a closing bracket -------------------------------------------------------------------------------- /RegEx/Code/README.ps1.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions that may be helpful in parsing language agonstic coding conventions. 2 | 3 | ~~~PipeScript{ 4 | Import-Module ../../Irregular.psd1 -Global 5 | $directoryName = $pwd | Split-Path -Leaf 6 | [PSCustomObject]@{ 7 | Table = Get-Regex -Name "${directoryName}_*" | 8 | Sort-Object Name | 9 | .Name { 10 | "[?<$($_.Name)>]($($_.Path | Split-Path -Leaf))" 11 | } .Description .Source { 12 | if ($_.IsGenerator) { 13 | "[generator]($($_.Path | Split-Path -Leaf))" 14 | } 15 | else { 16 | $sourcePath = $_.Path -replace '\.txt$', '.source.ps1' 17 | if (Test-Path $sourcePath) { 18 | "[source]($($sourcePath | Split-Path -Leaf))" 19 | } else { 20 | '' 21 | } 22 | } 23 | } 24 | }} 25 | ~~~ 26 | -------------------------------------------------------------------------------- /RegEx/Code/SemanticVersion.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a Semantic Version. See [https://semver.org/](https://semver.org/). 2 | (?0|[1-9]\d*) 3 | \. 4 | (?0|[1-9]\d*) 5 | \. 6 | (?0|[1-9]\d*) 7 | (?: 8 | - 9 | (?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*) 10 | (?: 11 | \. 12 | (?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*) 13 | )? 14 | (?: 15 | \+ 16 | (?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*) 17 | )? 18 | 19 | # This Regular Expression is slightly modified from the Regular Expression on [https://semver.org/](https://semver.org/). 20 | # It does not anchor the match, and thus will find multiple semantic versions within a string if they exist. 21 | -------------------------------------------------------------------------------- /RegEx/Colon.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches a literal colon 2 | \: -------------------------------------------------------------------------------- /RegEx/Console/24BitColor.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI 24-bit color" -Modifier IgnoreCase -Not | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or @( 8 | New-RegEx -Pattern '38' -Name IsForegroundColor 9 | New-RegEx -Pattern '48' -Name IsBackgroundColor 10 | New-RegEx -Pattern '58' -Name IsUnderlineColor 11 | ) | 12 | New-RegEx -Pattern ';2;' | 13 | New-RegEx -Name Color -Pattern ( 14 | New-Regex -Name Red -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Red is the first 0-255 value' | 15 | New-RegEx -Pattern ';' | 16 | New-Regex -Name Green -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Green is the second 0-255 value' | 17 | New-RegEx -Pattern ';' | 18 | New-Regex -Name Blue -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Blue is the third 0-255 value' | 19 | New-RegEx -Pattern 'm' 20 | ) | 21 | Set-Content -Path (Join-Path $myRoot $myName) 22 | -------------------------------------------------------------------------------- /RegEx/Console/24BitColor.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI 24-bit color 2 | (?-i)\e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?38) | 6 | (?48) | 7 | (?58));2;(?(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value 8 | ;(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value 9 | ;(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value 10 | m) 11 | -------------------------------------------------------------------------------- /RegEx/Console/4BitColor.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI 3 or 4-bit color 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?(?> 5 | (?1)?\;{0,1} # A 1 and a semicolon indicate a bright color 6 | (?3) # A number that starts with 3 indicates foreground color 7 | | 8 | (?(?9)) # OR it could be a less common bright foreground color, which starts with 9 9 | | 10 | (?1)?\;{0,1} # A 1 and a semicolon indicate a bright color 11 | (?4) # A number that starts with 3 indicates foreground color 12 | | 13 | (?(?10)) # OR it could be a less common bright foreground color, which starts with 9 14 | )(?[0-7]) # The color number will be between 0 and 7 15 | (?:\;{0,1}(?1)?)? # Brightness can also come after a color 16 | m) 17 | -------------------------------------------------------------------------------- /RegEx/Console/8BitColor.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI 8-bit color 2 | (?-i)\e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?38) | 6 | (?48) | 7 | (?58));5;(?(?> 8 | (?[0-7]) # 0 -7 are standard colors 9 | m | 10 | (?(?>[8-9]|1[0-5])) # 8-15 are bright colors 11 | m | 12 | (?(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2})) # 16-231 are cubed colors 13 | m | 14 | (?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # 232-255 are grayscales 15 | m)) 16 | -------------------------------------------------------------------------------- /RegEx/Console/Blink.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Blink Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "BlinkStart" -Atomic -Or @( 9 | New-RegEx -Name "BlinkSlow" -Pattern '5m' -Comment '5m starts a slow blink' 10 | New-RegEx -Name "BlinkFast" -Pattern '6m' -Comment '6m starts a slow blink' 11 | ) 12 | New-RegEx -Name "BlinkEnd" -Pattern '25m' -Comment "25m stops blinks" 13 | ) | 14 | Set-Content -Path (Join-Path $myRoot $myName) 15 | -------------------------------------------------------------------------------- /RegEx/Console/Blink.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Blink Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?> 6 | (?(?5m) # 5m starts a slow blink 7 | | 8 | (?6m) # 6m starts a slow blink 9 | )) | 10 | (?25m) # 25m stops blinks 11 | ) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Bold.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI Bold (aka bright) Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "BoldStart" -Pattern '1m' -Comment "1m starts bold" 9 | New-RegEx -Name "BoldEnd" -Pattern '22m' -Comment '22m stops bold' 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Bold.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI Bold Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?1m) | 6 | (?22m)) 7 | -------------------------------------------------------------------------------- /RegEx/Console/Code.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI escape code" -Modifier IgnoreCase -Not | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Name ParameterBytes ( 8 | New-Regex -CharacterClass Digit -LiteralCharacter ':;<=>?' -Min 0 9 | ) -Comment "Followed by zero or more parameter bytes" | 10 | New-RegEx -Name IntermediateBytes ( 11 | New-Regex -LiteralCharacter (0x21..0x2F -as [char[]]) -Min 0 -CharacterClass Whitespace 12 | ) -Comment "Followed by zero or more intermediate bytes" | 13 | New-RegEx -Name FinalByte ( 14 | New-RegEx -LiteralCharacter (0x40..0x7E -as [char[]]) 15 | ) -Comment "Followed by a final byte" | 16 | Set-Content -Path (Join-Path $myRoot $myName) 17 | -------------------------------------------------------------------------------- /RegEx/Console/Code.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI escape code 2 | (?-i)\e # An Escape 3 | \[ # Followed by a bracket 4 | (?[\d\:\;\<\=\>\?]{0,}) # Followed by zero or more parameter bytes 5 | (?[\s\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/]{0,}) # Followed by zero or more intermediate bytes 6 | (?[\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~]) # Followed by a final byte 7 | 8 | -------------------------------------------------------------------------------- /RegEx/Console/Color.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI color" | 5 | New-RegEx -Atomic -Or @( 6 | New-RegEx -Pattern '?' 7 | New-RegEx -Pattern '?' 8 | New-RegEx -Pattern '?' 9 | New-RegEx -Pattern '?' 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) -PassThru 12 | -------------------------------------------------------------------------------- /RegEx/Console/Console.tests.ps1: -------------------------------------------------------------------------------- 1 | describe 'Irregular Console Patterns' { 2 | it 'Can match any Escape sequence' { 3 | "$([char]0x1b)[0m" | ? | Select-Object -ExpandProperty Length | Should -be 4 4 | 5 | "$([char]0x1b)[1;3;5,~" | ? | Select-Object -ExpandProperty Length | Should -be 9 6 | } 7 | context 'Console Colors' { 8 | it 'Can Match a 4-bit color' { 9 | $x = "$([char]0x1b)[32m" | ? -Extract 10 | $x.ColorNumber | Should -Be 2 11 | $x.IsForegroundColor | Should -Be 3 12 | } 13 | 14 | it 'Can Match a 24-bit color' { 15 | $x = "$([char]0x1b)[38;2;255;100;0m" | ? -Extract 16 | $x.Red | Should -be 255 17 | $x.Green | Should -be 100 18 | $x.Blue | Should -be 0 19 | } 20 | } 21 | 22 | context 'Console Styles' { 23 | it 'Can Match Console Styles' { 24 | @("$([char]0x1b)[3m Italics $([char]0x1b)[23m" | ?).Count | Should -be 2 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /RegEx/Console/DefaultColor.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI default color" -Modifier IgnoreCase -Not | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Name Color -Pattern ( 8 | New-RegEx -Atomic -Or @( 9 | New-Regex -Name DefaultForeground -Pattern '39' -Comment '39 Represents the default foreground color' | 10 | New-RegEx -Pattern 'm' 11 | New-Regex -Name DefaultForeground -Pattern '49' -Comment '49 Represents the default background color' | 12 | New-RegEx -Pattern 'm' 13 | ) 14 | ) | 15 | Set-Content -Path (Join-Path $myRoot $myName) 16 | -------------------------------------------------------------------------------- /RegEx/Console/DefaultColor.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI 24-bit color 2 | (?-i)\e # An Escape 3 | \[ # Followed by a bracket 4 | (?(?> 5 | (?39) # 39 Represents the default foreground color 6 | m | 7 | (?49) # 49 Represents the default background color 8 | m)) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Faint.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI Faint (aka dim) Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "FaintStart" -Pattern '2m' -Comment "2m starts faint" 9 | New-RegEx -Name "FaintEnd" -Pattern '22m' -Comment '22m stops faint' 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Faint.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI Faint (aka dim) Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?2m) # 2m starts faint 6 | | 7 | (?22m) # 22m stops faint 8 | ) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Hide.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Hide (aka conceal) Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "HideStart" -Pattern '8m' -Comment "8m starts hide" 9 | New-RegEx -Name "HideEnd" -Pattern '28m' -Comment "28m stops hide" 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Hide.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Hide (aka conceal) Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?8m) # 8m starts hide 6 | | 7 | (?28m) # 28m stops hide 8 | ) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Invert.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Invert Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "InvertStart" -Pattern '7m' -Comment "7m starts invert" 9 | New-RegEx -Name "InvertEnd" -Pattern '27m' -Comment "27m stops invert" 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Invert.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Invert Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?7m) # 7m starts invert 6 | | 7 | (?27m) # 27m stops invert 8 | ) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Italic.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Italic Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "ItalicStart" -Pattern '3m' -Comment "3m starts italic" 9 | New-RegEx -Name "ItalicEnd" -Pattern '23m' -Comment '23m stops italic' 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Italic.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Italic Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?3m) # 3m starts italic 6 | | 7 | (?23m) # 23m stops italic 8 | ) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Link.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Hyperlink" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter ']' -Comment 'Followed by a right bracket' | 7 | New-RegEx -Pattern '8[^;]{0,};;' -Comment 'Followed by 8 (and optional non-semicolon content) and two semicolons' | 8 | New-RegEx -Until '\e' -Name Uri -Comment 'Followed by the uri' | 9 | New-RegEx -CharacterClass Escape -Comment 'Followed by an escape' | 10 | New-RegEx -LiteralCharacter '\' -Comment 'Followed by a slash' | 11 | New-RegEx -Until '\e' -Name Text -Comment 'Followed by the link text' | 12 | New-RegEx -CharacterClass Escape -Comment 'Followed by an escape' | 13 | New-RegEx -LiteralCharacter ']' -Comment 'Followed by a right bracket' | 14 | New-RegEx -Pattern '8[^;]{0,};;' -Comment 'Followed by 8 (and optional non-semicolon content) and two semicolons' | 15 | New-RegEx -CharacterClass Escape -Comment 'Followed by an Escape' | 16 | New-RegEx -LiteralCharacter '\' -Comment 'Finally a closing slash' | 17 | Set-Content -Path (Join-Path $myRoot $myName) 18 | -------------------------------------------------------------------------------- /RegEx/Console/Link.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Hyperlink 2 | \e # An Escape 3 | \] # Followed by a right bracket 4 | 8[^;]{0,};; # Followed by 8 and two semicolons 5 | (?(?:.|\s){0,}?(?=\z|\e)) # Followed by the uri 6 | \e # Followed by an escape 7 | \\ # Followed by a slash 8 | (?(?:.|\s){0,}?(?=\z|\e)) # Followed by the link text 9 | \e # Followed by an escape 10 | \] # Followed by a right bracket 11 | 8[^;]{0,};; # Followed by 8 and two semicolons 12 | \e # Followed by an Escape 13 | \\ # Finally a closing slash 14 | 15 | -------------------------------------------------------------------------------- /RegEx/Console/README.ps1.md: -------------------------------------------------------------------------------- 1 | This directory contains regular expressions for advanced console features, such as [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code). 2 | 3 | Note: Using these regular expressions in the terminal may result in awkward output. (the .Match will contain an escape sequence, which will make the next output attempt to use this escape sequence) 4 | 5 | ~~~PipeScript{ 6 | Import-Module ../../Irregular.psd1 -Global 7 | $directoryName = $pwd | Split-Path -Leaf 8 | [PSCustomObject]@{ 9 | Table = Get-Regex -Name "${directoryName}_*" | 10 | Sort-Object Name | 11 | .Name { 12 | "[?<$($_.Name)>]($($_.Path | Split-Path -Leaf))" 13 | } .Description .Source { 14 | if ($_.IsGenerator) { 15 | "[generator]($($_.Path | Split-Path -Leaf))" 16 | } 17 | else { 18 | $sourcePath = $_.Path -replace '\.txt$', '.source.ps1' 19 | if (Test-Path $sourcePath) { 20 | "[source]($($sourcePath | Split-Path -Leaf))" 21 | } else { 22 | '' 23 | } 24 | } 25 | } 26 | }} 27 | ~~~ -------------------------------------------------------------------------------- /RegEx/Console/Reset.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI Reset (this clears formatting)" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Name "Reset" -Pattern '0m' -Comment "0m indicates reset" | 8 | Set-Content -Path (Join-Path $myRoot $myName) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Reset.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches an ANSI Reset (this clears formatting) 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?0m) # 0m indicates reset 5 | 6 | -------------------------------------------------------------------------------- /RegEx/Console/Strikethrough.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Strikethrough (aka crossed out) Start or End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "StrikethroughStart" -Pattern '9m' -Comment "9m starts Strikethrough" 9 | New-RegEx -Name "StrikethroughEnd" -Pattern '29m' -Comment "29m stops Strikethrough" 10 | ) | 11 | Set-Content -Path (Join-Path $myRoot $myName) 12 | -------------------------------------------------------------------------------- /RegEx/Console/Strikethrough.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Strikethrough Start or End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?9m) # 9m starts Strikethrough 6 | | 7 | (?29m) # 29m stops Strikethrough 8 | ) 9 | -------------------------------------------------------------------------------- /RegEx/Console/Style.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches an ANSI style (color or text option)" | 5 | New-RegEx -Atomic -Or @( 6 | New-RegEx -Pattern '?' 7 | New-Regex -Pattern '?' 8 | New-Regex -Pattern '?' 9 | New-Regex -Pattern '?' 10 | New-Regex -Pattern '?' 11 | New-Regex -Pattern '?' 12 | New-Regex -Pattern '?' 13 | New-Regex -Pattern '?' 14 | New-Regex -Pattern '?' 15 | New-RegEx -Pattern '?' 16 | New-RegEx -Pattern '?' 17 | New-RegEx -Pattern '?' 18 | New-RegEx -Pattern '?' 19 | ) | 20 | Set-Content -Path (Join-Path $myRoot $myName) -PassThru 21 | -------------------------------------------------------------------------------- /RegEx/Console/Underline.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matches ANSI Underline/DoubleUnderline Start or Underline End" | 5 | New-RegEx -CharacterClass Escape -Comment 'An Escape' | 6 | New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' | 7 | New-RegEx -Atomic -Or -Pattern @( 8 | New-RegEx -Name "UnderlineStart" -Pattern '4m' -Comment "4m starts underline" 9 | New-RegEx -Name "DoubleUnderlineStart" -Pattern '21m' -Comment '21m start a double underline' 10 | New-RegEx -Name "UnderlineEnd" -Pattern '24m' -Comment "24m stops underline" 11 | ) | 12 | Set-Content -Path (Join-Path $myRoot $myName) 13 | -------------------------------------------------------------------------------- /RegEx/Console/Underline.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches ANSI Underline/DoubleUnderline Start or Underline End 2 | \e # An Escape 3 | \[ # Followed by a bracket 4 | (?> 5 | (?4m) # 4m starts underline 6 | | 7 | (?21m) # 21m start a double underline 8 | | 9 | (?24m) # 24m stops underline 10 | ) 11 | -------------------------------------------------------------------------------- /RegEx/Decimals.regex.txt: -------------------------------------------------------------------------------- 1 | # Matching any series of decimals is deceptively complicated 2 | (?\-)? # It might be start with a - 3 | (?:(?> # Then it can be either: 4 | (?\d+) # One or more digits (the Characteristic) 5 | (?:\.(?\d+)){0,1} # followed by a period and one or more digits (the Mantissa) 6 | | # Or it can be 7 | (?:\.(?\d+)) # just a Mantissa 8 | )) 9 | (?: 10 | E 11 | (? 12 | [+-]\d+ 13 | ) 14 | )? -------------------------------------------------------------------------------- /RegEx/Degrees.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | 4 | New-RegEx -Description "Matching degrees" | 5 | New-Regex -Pattern ? | 6 | New-RegEx -CharacterClass Whitespace -Min 0 -Comment "Optional Whitespace" | 7 | New-RegEx -Atomic -Or @("Degrees","Degree", "°") -Comment "Degree(s) or the degree symbol" | 8 | New-RegEx -CharacterClass Whitespace -Min 0 -Comment "Optional Whitespace" | 9 | New-RegEx -Name UnitType -Optional -Pattern $( 10 | New-RegEx -Atomic -Or @( 11 | "Celsius" 12 | "C" 13 | "Fahrenheit" 14 | "F" 15 | ) 16 | ) -Comment "Optional unit" | 17 | Set-Content -Path (Join-Path $myRoot $myName) 18 | -------------------------------------------------------------------------------- /RegEx/Digits.regex.txt: -------------------------------------------------------------------------------- 1 | # Repeated Digits 2 | \d+ 3 | -------------------------------------------------------------------------------- /RegEx/DoubleQuotedString.regex.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Matches double-quoted strings. 4 | .Description 5 | Matches a double quoted string, with an optional escape sequence (defaulting to backtick or backslash). 6 | #> 7 | param( 8 | # The escape character 9 | [string] 10 | $Escape 11 | ) 12 | 13 | 14 | if ($inputObject) { 15 | if ($inputObject -is [IO.FileInfo]) { 16 | $escape = 17 | if ('.h', '.cpp', '.c', '.cs', '.js', '.java','.json', '.htm', '.html', '.xml', '.pswt' -contains $inputObject.Extension) { 18 | '\' 19 | } elseif ('.ps1', '.psm1', '.psd1' -contains $inputObject.Extension) { 20 | '`' 21 | } 22 | 23 | if (-not $Escape) { return } 24 | } 25 | if ($inputObject -is [Management.Automation.CommandInfo] -or 26 | $inputObject -is [ScriptBlock]) { 27 | $Escape = '`' 28 | } 29 | if (-not $Escape) { return } 30 | } 31 | 32 | 33 | if ($Escape) { 34 | $escape = $escape -replace '[\p{P}\p{S}]', '\$0' 35 | "(?\w # Match the username, which starts with a word character 3 | [\w\-\.]{0,} # and can contain any number of word characters, dashes, or dots 4 | )\@ # Followed by an @ 5 | (?\w # The domain starts with a word character 6 | [\w\-]{0,} # and can contain any words with dashes, 7 | (?:\. # followed by at least one suffix (which starts with a dot), 8 | \w # followed by a word character, 9 | [\w\-]{0,} # followed by any word characters or dashes 10 | ){1,}) 11 | -------------------------------------------------------------------------------- /RegEx/Equals.regex.txt: -------------------------------------------------------------------------------- 1 | # A literal equal sign = 2 | = -------------------------------------------------------------------------------- /RegEx/FFmpeg/Configuration.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description @' 4 | Matches FFMpeg configuration 5 | '@ -StartAnchor LineStart -Pattern "\s{0,}configuration:" -Comment "Configuration: is followed by any number of flags" | 6 | Write-RegEx -NoCapture -Min 0 -Pattern ( 7 | Write-RegEx -CharacterClass Whitespace -Repeat | 8 | Write-RegEx -LiteralCharacter '-' | 9 | Write-RegEx -LiteralCharacter '-' | 10 | Write-RegEx -CharacterClass NonWhitespace -Repeat -Name Flag -Comment "A flag is two dashes, followed by any number of non-whitespace characters" 11 | ) | 12 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 13 | 14 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Configuration.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches FFMpeg configuration 2 | ^\s{0,}configuration: # Configuration: is followed by any number of flags 3 | (?:\s+\-\-(?\S+) # A flag is two dashes, followed by any number of non-whitespace characters 4 | ){0,} 5 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Input.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description @' 4 | Matches FFMpeg inputs 5 | '@ -StartAnchor LineStart -Pattern "\s{0,}Input\s{0,}\#" -Comment "An Input starts with the literal 'Input', followed by a space a number sign" | 6 | Write-RegEx -Name FileNumber -CharacterClass Digit -Repeat -Comment "Followed by an file number and a comma" | 7 | Write-RegEx -LiteralCharacter ',' | 8 | Write-RegEx -CharacterClass Whitespace -Min 0 | 9 | Write-RegEx -NoCapture -Min 0 -Pattern ( 10 | Write-RegEx -Name Container -Not -LiteralCharacter ',' -CharacterClass Whitespace -Repeat | 11 | Write-RegEx -LiteralCharacter ',' -Min 0 12 | ) -Comment "Followed by container information (separated by commas)" | 13 | Write-RegEx -CharacterClass Whitespace -LiteralCharacter ',' -Min 0 | 14 | Write-RegEx -Pattern 'from' -Comment "Followed by 'from'" | 15 | Write-RegEx -CharacterClass Whitespace -Min 0 | 16 | Write-RegEx -Pattern "(?(?:''|\\'|[^'])*)'" -Comment "Followed by the InputPath, in a single quoted string." | 17 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 18 | 19 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Input.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches FFMpeg inputs 2 | ^\s{0,}Input\s{0,}\# # An Input starts with the literal 'Input', followed by a space a number sign 3 | (?\d+) # Followed by an file number and a comma 4 | \,\s{0,}(?:(?[^\s\,]+)\,{0,}){0,} # Followed by container information (separated by commas) 5 | [\s\,]{0,}from # Followed by 'from' 6 | \s{0,}(?(?:''|\\'|[^'])*)' # Followed by the InputPath, in a single quoted string. 7 | 8 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Metadata.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description @' 4 | Matches FFMpeg metadata 5 | '@ -StartAnchor LineStart -Pattern "\s{4,}" -Comment "Metadata can occur on any line, as long as there are at least four spaces at the start" | 6 | Write-RegEx -Name Key -Not -CharacterClass Whitespace -LiteralCharacter ':' -Repeat -Optional -Comment "It may contain a key" | 7 | Write-RegEx -CharacterClass Whitespace -Min 0 -Comment "Followed by optional whitespace and a colon" | 8 | Write-RegEx -LiteralCharacter ':' | 9 | Write-RegEx -CharacterClass Whitespace -Min 1 -Comment "Ignore leading whitespace" | 10 | Write-RegEx -Until (Write-RegEx -CharacterClass NewLine, CarriageReturn) -Name Value -Comment "Anything until the end of the line is the value" | 11 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 12 | 13 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Metadata.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches FFMpeg metadata 2 | ^\s{4,} # Metadata can occur on any line, as long as there are at least four spaces at the start 3 | (?[^\s\:]+)? # It may contain a key 4 | \s{0,} # Followed by optional whitespace and a colon 5 | \:\s{1,} # Ignore leading whitespace 6 | (?(?:.|\s){0,}?(?=\z|[\n\r])) # Anything until the end of the line is the value 7 | 8 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Output.regex.source.ps1: -------------------------------------------------------------------------------- 1 | $myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' 2 | $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path 3 | Write-RegEx -Description @' 4 | Matches FFMpeg outputs 5 | '@ -StartAnchor LineStart -Pattern "\s{0,}Output\s{0,}\#" -Comment "An Input starts with the literal 'Input', followed by a space a number sign" | 6 | Write-RegEx -Name FileNumber -CharacterClass Digit -Repeat -Comment "Followed by an file number and a comma" | 7 | Write-RegEx -LiteralCharacter ',' | 8 | Write-RegEx -CharacterClass Whitespace -Min 0 | 9 | Write-RegEx -NoCapture -Min 0 -Pattern ( 10 | Write-RegEx -Name Container -Not -LiteralCharacter ',' -CharacterClass Whitespace -Repeat | 11 | Write-RegEx -LiteralCharacter ',' -Min 0 12 | ) -Comment "Followed by container information (separated by commas)" | 13 | Write-RegEx -CharacterClass Whitespace -LiteralCharacter ',' -Min 0 | 14 | Write-RegEx -Pattern 'to' -Comment "Followed by 'to'" | 15 | Write-RegEx -CharacterClass Whitespace -Min 0 | 16 | Write-RegEx -Pattern "(?(?:''|\\'|[^'])*)'" -Comment "Followed by the OutputPath, in a single quoted string." | 17 | Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru 18 | 19 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Output.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches FFMpeg outputs 2 | ^\s{0,}Output\s{0,}\# # An Input starts with the literal 'Input', followed by a space a number sign 3 | (?\d+) # Followed by an file number and a comma 4 | \,\s{0,}(?:(?[^\s\,]+)\,{0,}){0,} # Followed by container information (separated by commas) 5 | [\s\,]{0,}to # Followed by 'to' 6 | \s{0,}(?(?:''|\\'|[^'])*)' # Followed by the OutputPath, in a single quoted string. 7 | 8 | -------------------------------------------------------------------------------- /RegEx/FFmpeg/Progress.regex.txt: -------------------------------------------------------------------------------- 1 | # Matches Progress Lines in FFMpeg output 2 | ^frame= # frame= 3 | \s{0,}(?\d+)\s{0,} # Followed by the Frame Number 4 | fps= # fps= 5 | \s{0,}(?[\d\.]+)\s+ # Followed by Frames Per Second 6 | q= # q= 7 | (?[\d\.]+)\s+ # Followed by the Quanitizer Scale 8 | L?size= # size= 9 | \s+(?\d{1,}\wB)\s+ # Followed by the Size 10 | time= # time= 11 | (?