lost in regular expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to parse the title and url out of a bunch of menu javascript
statements to convert a Macromedia menu to ASP.NET menu control.

The line I'm searching is of the form:
mm_menu_1222090555_0.addMenuItem("MyTitle","window.open('MyURL.htm',
'_self');");

The regex I came up (which doesn't match) is:
r = new Regex(@"addMenuItem.""(?<1>.#)"".*window.open.'(?<2>.#)'"

Thanks for any help with this
 
I figured it out, I was getting confused between industry standard Regex
quantifiers and MS proprietary versions

e.g. for minimal match I was using .# whereas MS uses .*?
 
Dabbler said:
I figured it out, I was getting confused between industry standard
Regex quantifiers and MS proprietary versions

e.g. for minimal match I was using .# whereas MS uses .*?

..*? is the industry standard (and ECMA standard) way of specifying minimal
match, AFIAK. Where have you seen a regex that uses .# ?

-cd
 
You're right Carl, I stand corrected. I've been using Regular Expressions in
editors to modify text so much I didn't realize that's where I got my
"industry standard" view. And to make matters worse it's MS that is using
different syntax in their VS IDE vs the Regex library in C#. For instance .#
is used for minimal matching in IDE vs .+? in Regex library.VS IDE uses {} to
tag expressions compared to () in the library. That's where my confusion came
from.

Thanks for clearing that up.
 
Dabbler said:
You're right Carl, I stand corrected. I've been using Regular
Expressions in editors to modify text so much I didn't realize that's
where I got my "industry standard" view. And to make matters worse
it's MS that is using different syntax in their VS IDE vs the Regex
library in C#. For instance .# is used for minimal matching in IDE vs
.+? in Regex library.VS IDE uses {} to tag expressions compared to ()
in the library. That's where my confusion came from.

Thanks for clearing that up.

No problem.

The whacky idea that the VS IDE has of regular expressions drives me up a
wall! Here they've got this lovely, ECMA-compliant regex library in .NET,
and VS uses it's own, one of a kind, proprietary flavor of regex. Go
figure.

-cd
 
Back
Top