ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Regex help, please?

(1/2) > >>

jpprater:
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:
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:
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:
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:
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.)

Navigation

[0] Message Index

[#] Next page

Go to full version