Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Regular Express Help Needed Please!

Reply
Thread Tools

Regular Express Help Needed Please!

 
 
Raj.SB
Guest
Posts: n/a
 
      01-28-2004
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.
 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      01-28-2004
"Raj.SB" <sgmuser#rediffmail.com> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
 
Raj.SB
Guest
Posts: n/a
 
      01-28-2004
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?


 
Reply With Quote
 
Raj.SB
Guest
Posts: n/a
 
      01-28-2004
<%
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>"
%>
 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      01-28-2004
"Raj.SB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <%
> 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


 
Reply With Quote
 
Raj.SB
Guest
Posts: n/a
 
      01-28-2004
Chri
how silly iam...thanks!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed on this 857W config. Repost to be clearer what the problemsare and the help needed sparticle Cisco 3 08-30-2007 07:47 PM
Urgent help needed in Regular expressions Raghu Raman ASP .Net 2 03-23-2005 05:26 AM
quick help needed on regular expression validator David Cho ASP .Net 4 02-15-2005 09:47 AM
Regular Expressions Guru needed. Please help! Andreas Klemt ASP .Net 0 08-18-2004 07:48 AM
Regular Expressions help needed Andreas Klemt ASP .Net 0 08-17-2004 11:04 AM



Advertisments