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

Strip Characters from String

Status
Not open for further replies.

vvicin01

Programmer
Aug 14, 2001
21
0
0
US
I need to remove some characters from a string. For example, in the filename test-e.html I want to remove the
-e.html from the string so the it reads test. How do I do this?
 
depends on how you determine what you want to replace/remove...

str = "test-e.html"
newStr = replace(str, "-.html", "")

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
If a hyphen is always going to be your delimeter, then you can use:

Code:
newString = oldString.substring(0, oldString.indexOf("-"));

--Dave
 
depends on how you determine what you want to replace/remove...

str = "test-e.html"
newStr = replace(str, "-e.html", "")

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
doh - thought I was in the asp forum - doh!!!


Sorry.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top