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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace function with wildcard 1

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
0
0
CA
To make a long story short, I am looking for a way to use the replace function with a wildcard in the find argument.

something like:

replace("Hello, I hope this works as expected","work*","")

which should theoretically give me: "Hello, I hope this".

Basically, I want to replace "works" and everything that follows with an empty string.

I guess I don't know where to place the wildcard character *
I've tried everything and "works"* gives me following error: Compile error: Expected: expression

This must be so simple but yet .....

Thanks for any suggestion.

Mike
 
I think I'd consider using a different function (or combination of functions).

[tt]if instr(strText,"Works")>0 then
strText=mid$(strText, 1, instr(strText,"Works")-1)
end if[/tt]

Roy-Vidar
 
RoyVidar

Your suggestion was brilliant. I needed to adapt it to my script and bam !

Thank you so much !

I really appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top