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!

manipulating a small string for its chars 2

Status
Not open for further replies.

scottRen

Technical User
Feb 4, 2005
69
0
0
CA
string: 4-20-2005

how can i set a2a to be the value of the numbers to the left of the first -

a3a to be the number between each -

and a4a to be the last four number at the end of the string

possible variations on the string are:
12-11-2001
3-9-2005
13-5-2002
2-19-2003
 
maybe i'm reeading your question wrong but is this what you want

Code:
string="4-20-2005"
'new string now
string="a2a-a3a-a4a"
'string now equals a2a-a3a-a4a
 
i have a string via url to another page, the string consists of the day-month-year, in a format like: xx-xx-xxxx
I would like to set a var (lets say a2a) to the number to the left of the first hyphen, then set a3a to the numbers between the hypens and finally set a4a to the numbers after the last hypen,
something like so:

a2a=(number to the left of the hypen)
a3a=(number between the hypens)
a4a=(number to the right of the last hypen, or the last four number of the string cause they are always in teh format of 4 numbers. where as the a2a could be 1 number or 2 nuymbers... same with the month (a3a)

thanks, hope that explains things better,sry
 
you could try splitting on the hyphen:
Code:
var_array = split(string_in_question,"-",-1,1)
a2a = var_array(0)
a3a = var_array(1)
a4a = var_array(2)

or at least something to that effect.
 
var_array = split(string_in_question,"-")
a2a = var_array(0)
a3a = var_array(1)
a4a = var_array(2)

will do
 
true. i'm just used to including the optional arguments.
 
why would you set the same variables everytime i don't know

you know you could just use the array values to call them

ex.

response.write var_array(0) & "-" & var_array(1) & "-"& var_array(2)
 
very true. once it's split into the array, there is no need for any additional variables.

and thanks for that star! haha.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top