Dynamical replacing

S

Sune

Hi,

I need to replace some dynamical content away from a text, only static thing
is that it starts with <!-- Start dynamic --> and ends with <!-- End dynamic
-->. How do i dynamical remove these two tags and all the content between
them?

Thank you very much.
 
E

Evertjan.

Sune wrote on 15 feb 2005 in microsoft.public.inetserver.asp.general:
I need to replace some dynamical content away from a text, only static
thing is that it starts with <!-- Start dynamic --> and ends with <!--
End dynamic -->. How do i dynamical remove these two tags and all the
content between them?

Where would you want to remove it?
In an asp-file on a server?

With what would you want to remove it?
With the execution of another(!) asp-file?
When that file is requested from clientside?
 
S

Sune

Where would you want to remove it? In an asp-file on a server?
With what would you want to remove it?
With the execution of another(!) asp-file?
When that file is requested from clientside?
Lets take the example that i have got the text/html in a database, and i
pull it out to the user when he requests the page. On-the-fly i want it removed
(and posssibly some of it replaced by something else), just like it's possible
to do with static content using the Replace function.

To explain it in another way, what i need is actually some solution that
works like the Replace function, but supports wildcards so i could do like
these examples:
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "")
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "Static text")

Got any ideas?
 
E

Evertjan.

Sune wrote on 15 feb 2005 in microsoft.public.inetserver.asp.general:
To explain it in another way, what i need is actually some solution
that works like the Replace function, but supports wildcards so i
could do like these examples:
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "")
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "Static
text")

Use VBS Regex replace:

<%

text = "1 11<!-- Start dynamic -->2 22<!-- End dynamic -->3 33"

regexstr = "<!-- Start dynamic -->.*<!-- End dynamic -->"

response.write ReplaceTest(text, regexstr, "")

Function ReplaceTest(text, patrn, replStr)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
ReplaceTest = regEx.Replace(text, replStr)
End Function

%>
 
T

Tim Slattery

To explain it in another way, what i need is actually some solution that
works like the Replace function, but supports wildcards so i could do like
these examples:
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "")
Replace(text, "<!-- Start dynamic -->*<!-- End dynamic -->", "Static text")

Assuming you're using VBScript, check the Replace method of the RegExp
object:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsmthreplace.asp

Set regEx = new RegExp
regEx.pattern = "(<!-- Start dynamic -->)(.*)(<!-- End dynamic -->)"

replStr = "<!-- Start dynamic -->something or other<!-- End dynamic
-->"

newStr = regEx.replace(replStr, "$1$3")

newStr now contains "<!-- Start dynamic --><!-- End dynamic -->"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top