Link to home
Start Free TrialLog in
Avatar of raymurphy
raymurphy

asked on

Removing unwanted characters from string content

Getting some data from database, and need to show it on classic asp web page.

Data coming from database for this particular string will always be in the format :
       
          n - XXXXXXX (numeric, space, hyphen, space followed by text), e.g :
 
          1 - RequiredText

So in the above example, I will be receiving "1 - RequiredText" from the database, but my asp page only needs to show RequiredText.

Any easy ways of doing this, please ?



Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

if it is always going to be the same, then you can try this.

<%=replace(rs("MyRecord,"1 - ","" ")%>

Carrzkiss
I was wrong on that. Wrote it up incorrectly.
Sorry
Avatar of raymurphy
raymurphy

ASKER

The example of "1 - RequiredText" was just an example - what I need to be able to do is strip the text after the numeric-space-hypen-space and then display that text ...

here you go (tested and works)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<%
myVar = (objRS("Field1"))
If myVar <> "" Then
%>

<%=Replace(myVar,"1 -","") %>
 <%
  End If
%>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Carrzkiss
sorry, did not refesh the page before posting.
Let me do some more checking.

Carrzkiss
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for this suggestion, Carrzkiss - I'll give it a go and let you know the outcome ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delay in getting back - both solutions worked fine, so I'm going to split accordingly and hop that's OK with you both. Thanks for the solutions - much appreciated.