Skip to content

The RE provided for the -match example is strange #11605

@marcmcd

Description

@marcmcd

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Links

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/docs-conceptual/learn/ps101/05-formatting-aliases-providers-comparison.md

Summary

The RE provided for the -match example is strange:
'PowerShell' -match '^*.shell$'
^* matches 0 or more of the "start of string" (of which there can only be one)
and then the . in .shell$ matches any single character before the ending
substring "shell" ("r" in this case).

  PS> 'PowerShell' -match '^*.shell$'
  True
  PS> $matches

  Name                           Value
  ----                           -----
  0                              rShell

Details

No response

Suggested Fix

I believe you intended to provide the following example instead:

  PS> 'PowerShell' -match '^.*shell$'
  True
  PS> $matches

  Name                           Value
  ----                           -----
  0                              PowerShell

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions