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!

Deleting numbers from the middle of a string. 1

Status
Not open for further replies.

dwhunt13

Technical User
Apr 22, 2010
10
0
0
US
I am new to Aspect scripting and I have a string (ends up being the filename) of approximately 26 characters that always has the date embedded as YYYYMMDD. I want to remove the date and the trailing space. There is a single character numeric prior to the date in this string. It is part of the site name (site1, site2, etc.), which is the first field in the string. What is the most efficient method to accomplish this?
 
Could you post some example strings (X out any sensitive data if necessary)? Does the date always appear in the same place numerically (i.e. 8th through 15th) in the string?

 
Thanks for your response knob!
String examples:

Alby1 20100422 5E 1db EAI
Brbrg 20100428 5E PV OMP
LIC2 20100427 DO PV retest
SaltL 20100504 5E SU HSFT

As you can see, the site name varies from site to site. It is not always a set number of characters to the start of the date field of the string. Although the date area always has a space in front of it and it is always after the first space in the string. It will also start with 20 for the next 89 years.
 
Here's some code that will do the trick:

proc main
string sLine
integer iHit

strfind sLine " " iHit
strdelete sLine iHit 9
endproc

sLine contains the string you are working with and iHit is an integer variable that stores the location of the first space in the string found by the strfind command. The strdelete command deletes the leading space and the eight character date string.

 
That did it! Thanks for your help Knob!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top