Skip to content

Rename Suggested: Write-RegEx should be New-RegEx #66

@HerbM

Description

@HerbM

** PREFACE: I love this. Thx.**

The documentation (readme and help) for Write-Regex states that:

Write-Regex -CharacterClass Digit -Repeat # This writes the Regex (\d+)

However, this only "writes" 3 blanks lines.

To Reproduce
Write-Regex -CharacterClass Digit -Repeat # This writes the Regex (\d+)

Expected behavior
Expect the pattern '\d+' to appear as the comment indicates.

Actual behavior
3 blank lines.
What is actually being "written" is the Regex object itself, since apparently there is a default formatter for regexes that produce this output.

Additional context
The following will show all of the object properties (as will | Format-Table *)

Write-Regex -CharacterClass Digit -Repeat | Select-Object *

The pattern can also be seen by accessing the "Pattern" property or using the ToString() method of the regex object.

This is not a bug in Irregular's cmdlets (IMO) but rather a serious issue in the documentation and help.

Write-* cmdlets (practically) all produce (some) screen output in the default case -- due to the formatters.

Those who don't understand GetType(), Get-Member, or using Format explicitly or Select-Object will have a hard time understanding what Write-Regex is actually doing.

I can't decide if this is truly non-standard behavior for a Write-* cmdlets or simply surprising because the result is so different (and the text is hidden).

However, it did cost me a few minutes, first thinking that maybe my 7.2 RC PowerShell was buggy, then trying it in 5.1, and finally investigating deeper.

I suspect many people will give up and walk away from it, and maybe even from this excellent module.

STRONGLY recommend

  1. Adding (much) more to the Description area of the Write-Regex Help
  2. Adding explanations in the existing examples
  3. Adding explicit examples to show how to display the fields.**

Metadata

Metadata

Labels

documentationImprovements or additions to documentation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions