Rexx Parse Cmdlet

Topics: Developer Forum
Mar 6, 2007 at 4:37 PM
Hi folks,

Following up from a discussion in the news group, I'd like to propose the addition of a Rexx-like "Parse" cmdlet. This is fundamentally designed for parsing strings and is honestly the most effective string parser I've ever used in all the (very numerous!) years I've been doing this stuff.

Basic syntax would be something like:

Parse <something> with <template>


$InputVar="This is some text to parse, from a file or something"
Parse $InputVar $Word1 . ", " $Word2 $null

{template syntax is really optimised to work with blank-delimited strings}
{note, "." in the template soaks up unwanted word(s) - this would probably need to be quoted for PS (or replaced with $null)}

Would result in:
$Word1 -> "This"
$Word2 -> "from"


Parse $InputVar $Word1 . ", " $Word2

Would result in:
$Word1 -> "This"
$Word2 -> "from a file or something"

Obviously there's a lot more to it than this, please see:

Basic Syntax:

Basic Parsing Templates:

More on Templates:

There's also a Perl implementation on CPAN at:
that might help - although the way the syntax works out in the Perl version isn't great.

PowerShell-like extensions might include:
(1) Supporting .Net Regexs in addition to the other patterns Parse has traditionally supported
(2) Supporting automatic assignment to a new object with named attributes supplied in the template

I'd really love to help out but I'm a C programmer from the 1980s who got sidetracked into admin/consultancy - so my C# is weak to say the least! More than happy to do anything I can to get involved though.

Good luck with the new release - been looking forward to the Vista version:-)

Chris Warwick
Mar 7, 2007 at 4:24 AM
Perhaps something like ?
Mar 7, 2007 at 7:34 AM
Yes, I've seen (and used) that - it's excellent. The reason I think there's still a place for the cmdlet I'm suggesting is down to simplicity. Somehow the Rexx version seems to have a very clean syntax that in the majority of cases will just work - but it still has the flexibility to cover more esoteric cases as necessary. Perhaps some of the extensions in Lee's function could be incorporated (such as mentioned above - the assignment of matches to objects and regex support) - but simplicity is the key. Definitely an 80-20 thing IMHO.