-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
** 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
- Adding (much) more to the Description area of the Write-Regex Help
- Adding explanations in the existing examples
- Adding explicit examples to show how to display the fields.**