A function to replace

# Thread: A function to replace

1. Junior Member
Join Date
Dec 1969
Posts
27

## A function to replace

My results are as follows:<BR><BR>NO_007<BR>YES_00<BR>N/A_00<BR><BR>I need to remove everything after the _ for displaying purposes.<BR><BR>Argh!<BR>Any clues? I can&#039;t Left 3, or Right 2 or 3 or<BR><BR>*head explodes*

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Two ways:

&#060;%<BR>Function NoTail( txt )<BR>&nbsp; &nbsp; Dim stopat<BR>&nbsp; &nbsp; stopat = InStr( txt, "_" ) - 1<BR>&nbsp; &nbsp; If stopat &#062; 1 Then txt = Left( txt, stopat )<BR>&nbsp; &nbsp; NoTail = txt<BR>End Function<BR>%&#062;<BR><BR>** OR **<BR>&#060;%<BR>Function NoTail( txt )<BR>&nbsp; &nbsp; Dim temp<BR>&nbsp; &nbsp; temp = Split( txt, "_" )<BR>&nbsp; &nbsp; NoTail = temp(0)<BR>End Function<BR>%&#062;<BR><BR>And then invoke either version via:<BR><BR>&#060;%<BR>raw1 = "NO_007"<BR>fixed1 = NoTail( raw1 )<BR>%&#062;<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
733

## RE: A function to replace

sure ya can, you can find what postion the "_" is in.. and left that number -1<BR><BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=92<BR><BR>enjoy<BR>

4. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: A function to replace

vartemp = NO_007 <BR>tmpStr = right(vartemp, (len(vartemp)-instr(vartemp,"_")))<BR>response.write tmpStr

5. Junior Member
Join Date
Dec 1969
Posts
27

## RE: Two ways:

thanks a billion Bill!

6. Senior Member
Join Date
Dec 1969
Posts
1,570

## nevermind...

bad example... listen to the other folks<BR><BR>I don&#039;t know what the hell I was smoking when I wrote that thread...

7. Senior Member
Join Date
Dec 1969
Posts
96,118

## HUH???

That FAQ talks about finding a value in an array.<BR><BR>There isn&#039;t any array here.<BR><BR>(And that FAQ needs *badly* to be rewritten!)<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•