How can I use replace to replace a dynamic string that is sent over to my
broswer using a wildcard?

Here is a snip of my code,

extract = Replace(extract, "href", "")

for example here is what the browser sees,

href="javascript:show('1','http://server/page.asp=FDR2dmwjDE%3Byt2q%26FDT7w%
7Cq612d4

but I want it to look like

" " instead

after the 'href' is a long string that is dynamically changed each time the
page is viewed, how can I use Replace to remove anything following the
'href' but nothing below that line of code?

Thanks in advance..

Re: Using Replace with wildcard by Suresh

Suresh
Wed Jul 20 09:35:58 CDT 2005

This should do the trick:

pos = InStr(extract, "href")
If pos > 0 Then
posOpenQuote = InStr(pos, extract, """")
posCloseQuote = InStr(posOpenQuote + 1, extract, """")
If posCloseQuote Then extract = Left$(extract, posOpenQuote) & Mid$(extract,posCloseQuote)
End If


- Suresh


Re: Using Replace with wildcard by Joshua

Joshua
Wed Jul 20 12:16:03 CDT 2005

Thanks!!!!!


"Suresh" <sureshsitaula@gmail.com> wrote in message
news:1121870158.362322.89230@g14g2000cwa.googlegroups.com...
> This should do the trick:
>
> pos = InStr(extract, "href")
> If pos > 0 Then
> posOpenQuote = InStr(pos, extract, """")
> posCloseQuote = InStr(posOpenQuote + 1, extract, """")
> If posCloseQuote Then extract = Left$(extract, posOpenQuote) &
Mid$(extract,posCloseQuote)
> End If
>
>
> - Suresh
>



Re: Using Replace with wildcard by Steve

Steve
Thu Jul 21 07:25:08 CDT 2005

Joshua C. Clark wrote:

> How can I use replace to replace a dynamic string that is sent over to my
> broswer using a wildcard?
>
> Here is a snip of my code,
>
> extract = Replace(extract, "href", "")
>
> for example here is what the browser sees,
>
> href="javascript:show('1','http://server/page.asp=FDR2dmwjDE%3Byt2q%26FDT7w%
> 7Cq612d4
>
> but I want it to look like
>
> " " instead
>
> after the 'href' is a long string that is dynamically changed each time the
> page is viewed, how can I use Replace to remove anything following the
> 'href' but nothing below that line of code?

Any time you want to search for a pattern in a string (e.g. use a
wildcard), use a regular expression.

Here's an example of my find-an-HTML-attribute pattern:

With New RegExp
.Pattern = "href=(?:([""'])[\s\S]*?\1|[^\s>]*)"
.IgnoreCase = True
.Global = True
newString = .Replace(oldString, "")
End With

"Introduction to Regular Expressions"
http://msdn.microsoft.com/library/en-us/script56/html/reconintroductiontoregularexpressions.asp

"Regular Expression Object Properties and Methods"
http://msdn.microsoft.com/library/en-us/script56/html/vtoriregularexpressionsobjectpropmeth.asp

--
Steve

Patriotism is the willingness to kill and be killed for trivial reasons.
-Bertrand Russell

Re: Using Replace with wildcard by Joshua

Joshua
Fri Jul 22 12:11:48 CDT 2005

Awesome thanks!


"Steve Fulton" <cerberus40@geemail.com> wrote in message
news:op.st9jfzn6i0ix9l@steve...
> Joshua C. Clark wrote:
>
> > How can I use replace to replace a dynamic string that is sent over to
my
> > broswer using a wildcard?
> >
> > Here is a snip of my code,
> >
> > extract = Replace(extract, "href", "")
> >
> > for example here is what the browser sees,
> >
> >
href="javascript:show('1','http://server/page.asp=FDR2dmwjDE%3Byt2q%26FDT7w%
> > 7Cq612d4
> >
> > but I want it to look like
> >
> > " " instead
> >
> > after the 'href' is a long string that is dynamically changed each time
the
> > page is viewed, how can I use Replace to remove anything following the
> > 'href' but nothing below that line of code?
>
> Any time you want to search for a pattern in a string (e.g. use a
> wildcard), use a regular expression.
>
> Here's an example of my find-an-HTML-attribute pattern:
>
> With New RegExp
> .Pattern = "href=(?:([""'])[\s\S]*?\1|[^\s>]*)"
> .IgnoreCase = True
> .Global = True
> newString = .Replace(oldString, "")
> End With
>
> "Introduction to Regular Expressions"
>
http://msdn.microsoft.com/library/en-us/script56/html/reconintroductiontoregularexpressions.asp
>
> "Regular Expression Object Properties and Methods"
>
http://msdn.microsoft.com/library/en-us/script56/html/vtoriregularexpressionsobjectpropmeth.asp
>
> --
> Steve
>
> Patriotism is the willingness to kill and be killed for trivial reasons.
> -Bertrand Russell