regex help/check needed

Discussion in 'ASP .Net' started by darrel, May 5, 2008.

  1. darrel

    darrel Guest

    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
     
    darrel, May 5, 2008
    #1
    1. Advertising

  2. darrel

    darrel Guest

    > 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
     
    darrel, May 5, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alvin Bruney - ASP.NET MVP

    Regex help needed

    Alvin Bruney - ASP.NET MVP, Sep 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    385
    Alvin Bruney - ASP.NET MVP
    Sep 16, 2005
  2. rh0dium

    Regex help needed

    rh0dium, Jan 10, 2006, in forum: Python
    Replies:
    8
    Views:
    364
    Michael Spencer
    Jan 11, 2006
  3. Pradnyesh Sawant

    help needed with regex and unicode

    Pradnyesh Sawant, Mar 4, 2008, in forum: Python
    Replies:
    2
    Views:
    708
    Mark Tolonen
    Mar 4, 2008
  4. Replies:
    3
    Views:
    794
    Reedick, Andrew
    Jul 1, 2008
  5. mat
    Replies:
    0
    Views:
    268
Loading...

Share This Page