Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 06, 2016, 08:10:55 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Regex help, please?  (Read 3213 times)

jpprater

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Regex help, please?
« on: February 02, 2010, 11:14:48 AM »
I'm trying to parse information in the audit log of a bunch of work tickets, which I've exported to a .CSV file.  I've pulled the data into Powershell and am doing my parsing using .NET's regular expression class.

What I want is to detect when a ticket's assigned group was changed.  That shows up in the ticket's audit log as "The assigned group was changed to Group_Name", where Group_Name is always some combination of upper/lowercase letters and underscores.
This being the case, the following regex should do it...
The assigned group changed to ([a-zA-Z]+(?:_[a-zA-Z]+)*)

Yet, when I run these tickets' audit logs through that regex, I get nothing.  Am I missing something?  Is there an option I should be setting someplace?  I already tried multiline vs singleline...

worstje

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 571
  • The Gent with the White Hat
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #1 on: February 02, 2010, 11:46:48 AM »
Hrm, I see nothing wrong with the regex but I never used .NET regexes so... Anyhow, try: The assigned group changed to ([a-zA-Z][_a-zA-Z]*) and see if that helps any.

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,115
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #2 on: February 02, 2010, 03:25:23 PM »
You want to search for
"The assigned group was changed to Group_Name" ?
or for
"The assigned group changed to Group_Name" ?

I would use
$found = $subject -cmatch 'The assigned group was changed to .+\b'
to match this line.
Here i search for text as is, and then for one-or-more of any-sign, till an word boundary

Did you need do get the Group_Name for further use?
The assigned group was changed to (.+\b)

You can also use:
The assigned group was changed to ([a-zA-Z_ ]+)
or
The assigned group was changed to ([\w_ ]+)

There are many possibles. To provide an valid RegEx it would be nice to see an real output from that audit log (anonymous-ed)

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,779
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #3 on: February 02, 2010, 04:58:57 PM »
I can't comprehend how secret your data is :-\, but dropping it into an online regex tester would reveal any mistakes you can make in one day ;)
I'd either drop it on www.regexlib.com/RETester.aspx or www.regextester.com (but the latter is Java based)

worstje

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 571
  • The Gent with the White Hat
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #4 on: February 02, 2010, 10:05:25 PM »
I can't believe I missed that. I even re-read the text thrice to make sure it wasn't something stupid like that. (In my defense, I was really really tired at the time.)

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 7,714
    • View Profile
    • The Blog of Deozaan
    • Read more about this member.
    • Donate to Member
Re: Regex help, please?
« Reply #5 on: February 03, 2010, 01:59:25 AM »
I don't know a lot about Regex, but here is another online Regex tester:

http://rereplace.com/


Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,769
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #6 on: February 03, 2010, 02:42:05 PM »
The free Expresso is my tool of choice.  :D

parkint

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 119
  • It's bad luck to be superstitious
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #7 on: February 09, 2010, 06:18:41 PM »
The free Expresso is my tool of choice.  :D
I just downloaded it, based on your recommendation here.  Thanks.

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,769
    • View Profile
    • Donate to Member
Re: Regex help, please?
« Reply #8 on: February 09, 2010, 06:26:29 PM »
No problem.  :Thmbsup: