Regular Expression Mystery

E

eBob.com

I have text such as the following ...

COLOR="#CCCCCC"><B>zona
de Belgrano...</B></FONT>

What I want to extract from such strings is, in this case, "Belgrano".

I have the following regular expression ...

Zona[\ \s]+(de)?[\ \s]+(?<zone>[\w\ ]+)(\.){0,3}(<(/)?BR>)?[\s\ ]*</FONT>

which may look more complicated than it needs to be but the complication is
necessary to accomodate other strings containing this "zona" information.

I have been playing with this in Expresso (http://www.ultrapico.com/) and I
get a match
up through the last "?". I also get a match on (<(/)?BR>)?[\s\ ]*</FONT>
although, curiously, it tells me that what matches is </FONT>
when I'd expect the matching string to be </B></FONT>

For this particular text I do not need the [\s\ ]* part of the pattern
(near the end),
but removing it does not help. Nor does substituting the equivalent \s*

I am completely stumped, so if someone can see my problem I would sure
appreciate it.

Thanks, Bob
 
K

Kerem Gümrükcü

Hi Bob,

sometimes you dont need to use complicated RegExp Patterns
to find strings inside a stream/string. What about using the String
classes Members like: String.Contains(), String.EndsWith(),
String.IndexOf(),String.IndexOf(),String.LastIndexOf(). They
will be sufficient if you just want to find a string like "zona" as
you said,...

Regards

Kerem

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top