| Posted By |
Discussion Topic: required string
|
|
jampu |
11-09-2005 @ 3:12 PM |
|
|
New Member
Posts: 48
Joined: Jun 2005
|
hi i need to get characters from a string at required position Ex : I need to get 5and6 characters from ASDFGHj string Can anyone help me with function
jampu
|
mquack |
11-09-2005 @ 3:42 PM |
|
|
Moderator
Posts: 1544
Joined: Jan 2005
|
<cfscript> variables.myChar = ""; variables.posToGet = "5,6"; variables.str = "abcdefghijklmnopqrstuvwxyz"; for (variables.i=1; variables.i LTE len(variables.str); variables.i=variables.i+1) { if (listFind(variables.posToGet, variables.i)) { variables.myChar = listAppend(variables.myChar, mid(variables.str, variables.i, 1)); if (listLen(variables.myChar) GTE listLen(variables.posToGet)) { break; } } } </cfscript>
This sample creates a comma-delimmited list of the characters that are in the positions that you select.
Or, if you know that you always want the character from position 5 in the string, you narrow it down to this...
<cfscript> variables.str = "abcdefghijklmnopqrstuvwxyz"; variables.myChar = mid(variables.str, 5, 1); </cfscript>
http://www.rachelqueensg.com
This message was edited by mquack on 11-9-05 @ 4:18 PM
|
jampu |
11-09-2005 @ 4:17 PM |
|
|
New Member
Posts: 48
Joined: Jun 2005
|
<cfset myString = "NAMBB"> <cfset string5=#ListGetAt(myString, 5)#> <cfset string6=#ListGetAt(myString, 6)#> <cfset appendstr=ListAppend('string5','string6')> <cfoutput>appendstr</cfoutput> hi im using this procedure to get strings but the error is have to convert string(mystring) to list . can anyone helpme
jampu
|
mquack |
11-09-2005 @ 4:22 PM |
|
|
Moderator
Posts: 1544
Joined: Jan 2005
|
Just curious here, but did you even bother reading my post? I gave you a sample (2 actually) that you can adapt to solve your problem. We're here to help, but not to do your work for you.
http://www.rachelqueensg.com
|
jampu |
11-09-2005 @ 4:31 PM |
|
|
New Member
Posts: 48
Joined: Jun 2005
|
oops sorry i havent seen your reply.thanku want to know how can i convert my string to list using split function.Not able to find any split function in documentation
jampu
|