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

quick problem... 1

Status
Not open for further replies.

mochalova

MIS
Sep 20, 2007
15
US
Please can someone help me out with this...
I have a query string in a url that contains both numbers and letters. I need to store the numbers in one session and the letters in another session variable. The numbers come before the letters. The numbers could be 3 to 7 digits long and then followed by letters. Can anyone please tell me how to strip the numbers out first and also then put the left over letters into a another session variable.

Example: 12345 (could be 3 to 7 digits long) needs to be in one session variable.
xxxxxxxxxx (could be any number of characters long) needs to be in another session variable.

Many thanks
 
<CFSET alphabegins = REFind('A-Za-z',URL.value)>
<CFIF alphabegins>
<CFSET num = Left(URL.value,alphabegins-1)>
<CFSET alpha = Mid(URL.value,alphabegins,999)>
<CFELSE>
<CFSET num = URL.value>
<CFSET alpha = ''>
</CFIF>

r937.com | rudy.ca
 
Thanks for your response r937.

I changed <CFSET alphabegins = REFind('A-Za-z',URL.value)>
to

<CFSET alphabegins = REFind('[A-Z|a-z]',URL.value)>

But this line is returning an error:
<CFSET num = Left(URL.value,alphabegins-1)>

I need to strip out the numbers separately from the letters.

Thanks



 
I got it,

I used rereplace:

<cfset num = rereplace(URL.value, "[^0-9]+", "", "all")>
<cfset str = rereplace(URL.value, "[^A-Za-z]+", "", "all")>

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top