Regular expressions question

Discussion in 'ASP General' started by ASP.Confused, Jul 26, 2004.

  1. ASP.Confused

    ASP.Confused Guest

    Ok. I have the following regular expression:

    re.Pattern = "style[^=]*=[^\""]*\""[^\""]*\"""

    It will grab any style attribute within HTML that uses double quotes, and
    put it in the re.Matches collection.

    Now, I want to include single quotes into this regular expression. Here's
    what I have so far:

    re.Pattern = "style[^=]*=[^\""']*(\""|\')[^\1]*\1"

    but it does not work. Got any suggestions?
     
    ASP.Confused, Jul 26, 2004
    #1
    1. Advertising

  2. "ASP.Confused" <anonymous@> wrote in message
    news:...
    > Ok. I have the following regular expression:
    >
    > re.Pattern = "style[^=]*=[^\""]*\""[^\""]*\"""
    >
    > It will grab any style attribute within HTML that uses double quotes, and
    > put it in the re.Matches collection.
    >
    > Now, I want to include single quotes into this regular expression. Here's
    > what I have so far:
    >
    > re.Pattern = "style[^=]*=[^\""']*(\""|\')[^\1]*\1"
    >
    > but it does not work. Got any suggestions?
    >
    >


    style\s*=\s*('[^']*'|"[^"]*")
     
    Chris Hohmann, Jul 26, 2004
    #2
    1. Advertising

  3. ASP.Confused

    ASP.Confused Guest

    Ok...I feel stupid now....I didn't realize it was that easy....


    "Chris Hohmann" <> wrote in message
    news:%...
    > "ASP.Confused" <anonymous@> wrote in message
    > news:...
    > > Ok. I have the following regular expression:
    > >
    > > re.Pattern = "style[^=]*=[^\""]*\""[^\""]*\"""
    > >
    > > It will grab any style attribute within HTML that uses double quotes,

    and
    > > put it in the re.Matches collection.
    > >
    > > Now, I want to include single quotes into this regular expression.

    Here's
    > > what I have so far:
    > >
    > > re.Pattern = "style[^=]*=[^\""']*(\""|\')[^\1]*\1"
    > >
    > > but it does not work. Got any suggestions?
    > >
    > >

    >
    > style\s*=\s*('[^']*'|"[^"]*")
    >
    >
     
    ASP.Confused, Jul 26, 2004
    #3
  4. "ASP.Confused" <anonymous@> wrote in message
    news:e4E1%...
    > Ok...I feel stupid now....I didn't realize it was that easy....
    >
    >
    > "Chris Hohmann" <> wrote in message
    > news:%...
    > > "ASP.Confused" <anonymous@> wrote in message
    > > news:...
    > > > Ok. I have the following regular expression:
    > > >
    > > > re.Pattern = "style[^=]*=[^\""]*\""[^\""]*\"""
    > > >
    > > > It will grab any style attribute within HTML that uses double quotes,

    > and
    > > > put it in the re.Matches collection.
    > > >
    > > > Now, I want to include single quotes into this regular expression.

    > Here's
    > > > what I have so far:
    > > >
    > > > re.Pattern = "style[^=]*=[^\""']*(\""|\')[^\1]*\1"
    > > >
    > > > but it does not work. Got any suggestions?
    > > >
    > > >

    > >
    > > style\s*=\s*('[^']*'|"[^"]*")
    > >
    > >


    Here's another, if you're itching to use a back reference:

    style\s*=\s*('|").*?\1
     
    Chris Hohmann, Jul 27, 2004
    #4
    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. Jay Douglas
    Replies:
    0
    Views:
    640
    Jay Douglas
    Aug 15, 2003
  2. ASP.Confused

    Question on regular expressions

    ASP.Confused, Jul 26, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    392
    ASP.Confused
    Jul 26, 2004
  3. jeffM
    Replies:
    3
    Views:
    399
    Alan Moore
    Feb 2, 2004
  4. Replies:
    9
    Views:
    507
    Roedy Green
    Jan 23, 2006
  5. Noman Shapiro
    Replies:
    0
    Views:
    258
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page