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

Get variable, minus first four characters

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I need to get a variable, but strip off the first four characters. I know I could use Right(variable, Number) if the number of characters after the first four was always the same, but in this case it is not.

All variables will start with: foo_
For example: foo_34859 or foo_234 or foo_2 or foo_23908487

How do I get only the characters after the underscore, regardless of how many there are?
 
You could try using the Replace function
Code:
<cfset NewVarName = #Replace(VarName, &quot;foo_&quot;, &quot;&quot;, &quot;ALL&quot;)#>
This will strip &quot;foo_&quot; from the value of your variable.





Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Figured it out:

<cfset c_id = right(x, len(x)-4)>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top