regex help/check needed

D

darrel

I'm trying to get the value of a TITLE tag in an HTML document.

I have this as my REGEX:

(\<title\>)(.[^+\<]*)

In plain english, I'm trying ot find two matches:

1 - the opening title tag (<title>)
2 - the text after the TITL tag up to the first less-than sign

So, if this is my test string:

<title>Google</title>

I want to match

1 - <title>

2 - Google

However, in my .net code, it only returns one group match and it's the whole
thing:

<title>Google

Is there an obvious error in my REGEX logic that would be causing this?

-Darrel
 
D

darrel

However, in my .net code, it only returns one group match and it's the
whole thing:

<title>Google


As I read more into this, I'm thinking that's actually the correct behavior.
The MatchCollection is every instance of a match of my FULL regex.

So, I guess the better question is: how do I get the regex groupings (ie,
the stuff between the () parenthesis) individually?

I want to find <title>something

and then just keep 'something'.

I could use string functions to just trim the 7 characters, which would work
in this case, but am curious as to whether one can access the individual
regex groups for each match in the matchcollection.

-Darrel
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top