DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

jpprater

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • Participated in NANY Challenge Once
Regex help, please?
« on: February 02, 2010, 05:14 PM »
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

  • The Gent with the White Hat
  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 589
    • Coding Snacks
    • Participated in NANY Challenge Three Times
Re: Regex help, please?
« Reply #1 on: February 02, 2010, 05:46 PM »
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

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: Regex help, please?
« Reply #2 on: February 02, 2010, 09:25 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)
Greetings, Stefan.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Regex help, please?
« Reply #3 on: February 02, 2010, 10:58 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)
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

worstje

  • The Gent with the White Hat
  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 589
    • Coding Snacks
    • Participated in NANY Challenge Three Times
Re: Regex help, please?
« Reply #4 on: February 03, 2010, 04:05 AM »
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
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Re: Regex help, please?
« Reply #5 on: February 03, 2010, 07:59 AM »
I don't know a lot about Regex, but here is another online Regex tester:

http://rereplace.com/

Tuxman

  • OMG not him again!
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,522
    • Participated in NANY Challenge Seven Times
Re: Regex help, please?
« Reply #6 on: February 03, 2010, 08:42 PM »
The free Expresso is my tool of choice.  :D
I bet when Cheetahs race and one of them cheats, the other one goes "Man, you're such a Cheetah!" and they laugh & eat a zebra or whatever.

parkint

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

Tuxman

  • OMG not him again!
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,522
    • Participated in NANY Challenge Seven Times
Re: Regex help, please?
« Reply #8 on: February 10, 2010, 12:26 AM »
No problem.  :Thmbsup:
I bet when Cheetahs race and one of them cheats, the other one goes "Man, you're such a Cheetah!" and they laugh & eat a zebra or whatever.

Original address: https://www.donationcoder.com/forum/index.php?topic=21590.0