Regex Library

Topics: Developer Forum
Apr 11, 2007 at 6:07 PM
Edited Apr 11, 2007 at 6:10 PM
What would guys think of adding a simple RegexLib variable to the PSCX profile? Say something like this:

# Regex lib
$regexlib = new-object psobject
Add-Member NoteProperty StripPowerShellComments '^(?>\s*)(?!#|$)' -Input $regexlib
I could see adding a bunch of standard-ish type regexes. End users could modify this in their profile to customize it to their particular needs.
Apr 13, 2007 at 7:16 PM
Edited Apr 13, 2007 at 9:27 PM
That makes sense to me, in terms of giving people more ideas about things they can do ... as long as you don't get carried away with default examples.

Although, I'm not sure I understand why make a custom object instead just using a hashtable?
Apr 14, 2007 at 3:47 AM
We don't have tab completion for hashtables at the moment but we do for custom objects.
Apr 17, 2007 at 5:21 PM
Edited Apr 17, 2007 at 5:24 PM
Ahhh.... Cool :)

I've got a hashtable called $C which I've been using to store long commands that I can never remember when I need them, and that (for whatever reason) I didn't think merited being their own scripts ... I put it in a script called MoreCommands.ps1 which I execute when I need one of them, so it's basically like my own personal cheat sheet.

$C = @{}
$C.conflicts = "gcm -type cmdlet,function,alias |group name |where {`$_.count -gt 1}"
$C.conflictdetails = "gcm -type cmdlet,function,alias |group name |where {`$_.count -gt 1} | gcm"

Anyway ... I have been using by just typing $C and copying from the list ... or sometimes by using 'exec' which I have aliased to Invoke-Expression ... now you're making me think I should have considered a custom object to make it easier.
May 21, 2007 at 4:27 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.