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

Remove first 2 characters if they are "$$" 1

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
On some occasions I have results that will show up with $$ as the first 2 characters - like $$Accord

But I do not want the ugly $$ showing in one table I put them into - how can I remove the $$ if they exist? "Insert witty remark here"

Stuart
 
Try the RmChr function

string = RmChr(Input, "$")

here a example from the ASP emporium

<%
Dim Input, Disallowed

' String to clean
Input = &quot;sjsvnw)68&Y469$T_W$(*T+}D|3567808SDK49SO&quot; & _
&quot;DJ0570570Gosdnp SNDFG_S(*GH-S570570GN*4 jwt jtj+W$T )&quot;

' Allow spaces, underscores and any integer or letter of the alphabet.
' Remove anything else...
Disallowed = &quot;[]+=)(*&^%$#@!|\/?><,{}:;.-~`'&quot; & chr(34) & vbCrLf & vbTab
Response.Write RmChr(Input, Disallowed) & &quot;<BR>&quot;

' remove spaces, tabs, linefeed carriagereturns...
Disallowed = &quot; &quot; & vbTab & vbCrLf
Response.Write RmChr(Input, Disallowed) & &quot;<BR>&quot;

' remove numbers...
Disallowed = &quot;0123456789&quot;
Response.Write RmChr(Input, Disallowed) & &quot;<BR>&quot;

' remove lower case letters...
Disallowed = lcase(&quot;abcdefghijklmnopqrstuvwxyz&quot;)
Response.Write RmChr(Input, Disallowed) & &quot;<BR>&quot;

' remove upper case letters...
Disallowed = ucase(&quot;abcdefghijklmnopqrstuvwxyz&quot;)
Response.Write RmChr(Input, Disallowed) & &quot;<BR>&quot;
%> provide tools to let people become their best.
 
how would you use this?

Put it in a dim - store it in a variable? put it in a input line?

&quot;Insert witty remark here&quot;

Stuart
 
declare the string as the input
so
DIM input
input = &quot;the string or value of something&quot;
In the code above you would only have to do this
' String to clean
Input = &quot;your sting here&quot;

and then the you disallowed the same using what you don't want being &quot;$&quot;

provide tools to let people become their best.
 
If you only want to remove the first 2 $ and not any other $ characters in the string you can try something like this:

<%
dim str
str = &quot;$$money&quot;
if mid(str,1,2) = &quot;$$&quot; then
' remove the first 2 characters because they are $$
Response.Write mid(str,3,len(str)-2)
else
Response.Write str
end if
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top