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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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, "|"))>
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?
Is there a reason you did not accept my answer, as it was correct and was also provided first?
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.
You can always open a request in Community Support
https://www.experts-exchange.com/Community_Support/General/
https://www.experts-exchange.com/Community_Support/#browseZones
https://www.experts-exchange.com/Community_Support/General/
https://www.experts-exchange.com/Community_Support/#browseZones
ASKER
Again, thank you for all your help.
That will not produce the results: Jordan Kent