Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace a string 1

Status
Not open for further replies.

alvinjones

Technical User
Nov 11, 2007
6
DE
I have a text variable which contains the following string
"<html xmlns=" /><body xmlns=" Develop and deliver into production a Pilot Claims Status Enquiry using Seagull Software</p></body></html>" I need to remove any text contained within the < > characters. I have tried using the Replace function with a wildcard but it does not remove them.

this is what I have tried

strcheck = "<html xmlns=" /><body xmlns=" Develop and deliver into production a Pilot Claims Status Enquiry using Seagull Software</p></body></html>"

strcheck = Replace(strcheck, "<*>", "")

What am I doing wrong?
 
Replace doesn't accept wildcards.

I suspect you'll either need to look at Regex or writing a little parsing routine that utilises the instr() and mid$() functions.
 
[tt]s="<html xmlns=[highlight]""[/highlight][highlight]""[/highlight]><head /><body xmlns=[highlight]""[/highlight][highlight]""[/highlight]><p>Design, Develop and deliver into production a Pilot Claims Status Enquiry using Seagull Software</p></body></html>"

set rx=new regexp
with rx
.global=true
.pattern="(<)[\s\S]*?(>)" '() is preparing for alternative below, otherwise no need
end with
'[1] alternative: within means within
'> I need to remove any text contained [highlight]within[/highlight] the < > characters
t=rx.replace(s,"$1$2")
'[2] within means including <>
u=rx.replace(s,"")[/tt]

ps: For unbalanced and/or nested <>, the above is flawed and in fact the question would not be well-posed neither. But that kind of constraint is government by the well-formedness spec of the source (s).
pps: Declarations and references have to be taken care by yourself.
 
alvinjones, did you find tsuji's post useful?
if so why not thank him with a star.

Don't count the days, Make the days count.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top