List Info

Thread: Can't figure out why this regex doesn't match pattern




Can't figure out why this regex doesn't match pattern
user name
2006-02-24 12:52:21
Hi All,

I can't figure out why this regex:
"[(thusmiannqa01)|(thusmiannsql13)] -
[(agr)|(dm)|(emp)|(hp)|(mcd)|(ssc)]\w*"

does not match this pattern:
"thusmiannqa01 - emp30_206_bld_sec_sc19"

The string before the dash does not match, but the string
after the
dash does match. I'm at wits end with this one. Can anyone
see what I'm
missing?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Can't figure out why this regex doesn't match pattern
user name
2006-02-24 14:55:01
"Everyone" <matt.slavicekgmail.com> wrote:
>I can't figure out why this regex:
>"[(thusmiannqa01)|(thusmiannsql13)] -
>[(agr)|(dm)|(emp)|(hp)|(mcd)|(ssc)]\w*"

A number of problems.  The biggest one is that you're
putting groups in []
-- [] is for character classes not groups of text -- you
could put [a-z] to
match a-z but putting (thusmian etc. in there is causing it
to literally
look for the letters in that class in no particular order.

Try this one:
I've made most of the parenthetical capture groups
non-capturing with (?
-- so this match should include just 3 backreferences --
thusmiannqua02,
emp, and 30...etc.

((?:thusmiannqa01)|(?:thusmiannsql13)) -
((?:agr)|(?:dm)|(?:emp)|(?:hp)|(?:mcd)|(?:ssc))([\w]+)


-- 
Remember, no matter where you go, there you are. -Buckaroo
Banzai
Online Regex find/repalce utility: http://rereplace.com
Command-based online image editor: http://theprawn.com/imag
iine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Can't figure out why this regex doesn't match pattern
user name
2006-02-24 16:01:34
Ok, I replaced the square brackets with parens, and that did
the trick.
I think that's all I need.

I'm not sure what the difference is between a capturing
group and
non-capturing group. Could you elaborate a little on that?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )