Link to home
Start Free TrialLog in
Avatar of jramos74
jramos74

asked on

Coldfusion Data Manipulation

How do I extract a specific string from a given data.

For example:
I have a column name from a table labeled Name.  And this column contains the following data.

Name = Student: Senior | Jordan Kent | 2009

How do I extract just the name Jordan Kent?

Thanks

SOLUTION
Avatar of duncancumming
duncancumming
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> <cfset student = ListGetAt(name, 2, " | ")>

That will not produce the results:  Jordan Kent
Right enough, I forget that the 3rd parameter of ListGetAt is a list of any delimiters, not a string equalling one delimiter.

This works instead:

<cfset student = Trim(ListGetAt(name, 2, "|"))>
I would also  recommend checking the list length before using listGetAt(..). That way the code can exit gracefully if the value isn't what is expected. Otherwise, you just get an ugly exception message.
jramos74,

Is there a reason you did not accept my answer, as it was correct and was also provided first?

Avatar of jramos74
jramos74

ASKER

I meant to split the points because both examples compliment each other.  I do not how to re-open this question so i can split the points.
Again, thank you for all your help.