Regular Express Help Needed Please!

Discussion in 'ASP General' started by Raj.SB, Jan 28, 2004.

  1. Raj.SB

    Raj.SB Guest

    I have a reg exp pattern as below works fine for the string : <param name="url" value="contents/cf_intro.htm" valuetype="ref">

    mObjRegExp.pattern="<param.+?value=""([^""]+)""

    But the same is not working for

    <param name="url" valuetype="ref" value="../fmmain/fmindex.htm"

    note that, i want to capture the url that comes after value=". if the value=" comes in the second place in the html tag it works. but if it comes in the 3rd position, then it doesn't work.
    Can anyone help me finding the problem and make it work for both?thanks in advance.
    Raj.SB, Jan 28, 2004
    #1
    1. Advertising

  2. "Raj.SB" <sgmuser#rediffmail.com> wrote in message
    news:...
    > I have a reg exp pattern as below works fine for the string : <param

    name="url" value="contents/cf_intro.htm" valuetype="ref">.
    >
    > mObjRegExp.pattern="<param.+?value=""([^""]+)"""
    >
    > But the same is not working for
    >
    > <param name="url" valuetype="ref" value="../fmmain/fmindex.htm">
    >
    > note that, i want to capture the url that comes after value=". if the

    value=" comes in the second place in the html tag it works. but if it
    comes in the 3rd position, then it doesn't work.
    > Can anyone help me finding the problem and make it work for

    both?thanks in advance.

    What does "not working" mean? Please show more code. I tested the
    regular expression you provided and it behaves as expected.
    Chris Hohmann, Jan 28, 2004
    #2
    1. Advertising

  3. Raj.SB

    Raj.SB Guest

    Hi Thanks for the reply first

    Not working means, the reg exp does not return the url in between the quotes after 'value=' from the following string
    <param name="url" valuetype="ref" value="../fmmain/fmindex.htm"> . it works for this string
    <param name="url" value="contents/cf_intro.htm" valuetype="ref">

    the only difference between these two is the string i try to capture comes second in the working one, but in the not working string it comes as the third. am i explaining it clearly?
    Raj.SB, Jan 28, 2004
    #3
  4. Raj.SB

    Raj.SB Guest

    RE: Attached the code for your reference

    <%
    strLine = "<param name=""url"" valuetype=""ref"" value=""contents/cf_intro.htm"">" 'will return nothing
    strLine = "<param name=""url"" value=""contents/cf_intro.htm"" valuetype=""ref"">" 'will return 'contents/cf_intro.htm'
    Set mObjRegExp = New RegExp
    mObjRegExp.IgnoreCase = True
    mObjRegExp.MultiLine = True
    mObjRegExp.Global = True

    If InStr(lcase(strLine),"<param name=""url"" value=") Then
    Response.write "StrLine(PARAM):"&strLine&"<BR>"

    'mObjRegExp.pattern="<param.+?value=""([^""]+)"""

    Set mObjMatches = mObjRegExp.Execute(strLine)

    If mObjMatches.Count = 0 Then
    Else
    DescriptionParam = mObjMatches.item(0).Value
    If Len(DescriptionParam) > 5 Then
    DescriptionParam = Mid(DescriptionParam, InStr(1,DescriptionParam, "value=""", vbTextCompare) + 7)
    DescriptionParam = Mid(DescriptionParam, 1, InStr(1, DescriptionParam, """", vbTextCompare)-1)
    ParamFlag = 1
    Else
    ParamFlag = 0
    End If
    End If
    Else 'Checking for Param applet links
    End If 'Checking for Param applet links
    Set mObjMatch = Nothing
    Set mObjMatches = Nothing
    Set mObjRegExp = Nothing
    Response.write "<BR>test : " & DescriptionParam & "<BR>"
    %>
    Raj.SB, Jan 28, 2004
    #4
  5. Re: Attached the code for your reference

    "Raj.SB" <> wrote in message
    news:...
    > <%
    > strLine = "<param name=""url"" valuetype=""ref""

    value=""contents/cf_intro.htm"">" 'will return nothing
    > strLine = "<param name=""url"" value=""contents/cf_intro.htm""

    valuetype=""ref"">" 'will return 'contents/cf_intro.htm'
    > Set mObjRegExp = New RegExp
    > mObjRegExp.IgnoreCase = True
    > mObjRegExp.MultiLine = True
    > mObjRegExp.Global = True
    >
    > If InStr(lcase(strLine),"<param name=""url"" value=") Then
    > Response.write "StrLine(PARAM):"&strLine&"<BR>"
    >
    > 'mObjRegExp.pattern="<param.+?value=""([^""]+)"""
    >
    > Set mObjMatches = mObjRegExp.Execute(strLine)
    >
    > If mObjMatches.Count = 0 Then
    > Else
    > DescriptionParam = mObjMatches.item(0).Value
    > If Len(DescriptionParam) > 5 Then
    > DescriptionParam = Mid(DescriptionParam,

    InStr(1,DescriptionParam, "value=""", vbTextCompare) + 7)
    > DescriptionParam = Mid(DescriptionParam, 1, InStr(1,

    DescriptionParam, """", vbTextCompare)-1)
    > ParamFlag = 1
    > Else
    > ParamFlag = 0
    > End If
    > End If
    > Else 'Checking for Param applet links
    > End If 'Checking for Param applet links
    > Set mObjMatch = Nothing
    > Set mObjMatches = Nothing
    > Set mObjRegExp = Nothing
    > Response.write "<BR>test : " & DescriptionParam & "<BR>"
    > %>


    Your outer IF statement checks for the following:

    InStr(lcase(strLine),"<param name=""url"" value=")

    This check fails for the first strLine listed.

    HTH
    -Chris Hohmann
    Chris Hohmann, Jan 28, 2004
    #5
  6. Raj.SB

    Raj.SB Guest

    Re: Attached the code for your reference

    Chri
    how silly iam...thanks!
    Raj.SB, Jan 28, 2004
    #6
    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. ad
    Replies:
    7
    Views:
    659
    Scott Allen
    Apr 11, 2005
  2. =?Utf-8?B?Q2FybCBNLg==?=
    Replies:
    4
    Views:
    2,470
    sivlookingforu
    Aug 7, 2006
  3. KK
    Replies:
    2
    Views:
    526
    Big Brian
    Oct 14, 2003
  4. brooksr
    Replies:
    3
    Views:
    326
    Jon Paal
    Dec 24, 2006
  5. Jake Henderson

    Visual Web Developer 2005 Express and SQL 2005 Express

    Jake Henderson, Mar 10, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    214
    Jake Henderson
    Mar 10, 2006
Loading...

Share This Page