• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trimming more than one Words

New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

I have a Name field in my DB which can have more than one name seperated by spaces. I want to trim this name-field to just one word while outputting.

Example:
"Michael Theodor John"

Is outputted as simply
"Michael"

I'm working with trimming and find but not quite getting it right. Anyone suggestions?

Thank you very much,
Henrik
TOPICS
Advanced techniques

Views

258

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Dec 20, 2006 Dec 20, 2006
you can treat the name as a space-delimited list and use the ListGetAt function to get the first element of the list:

<cfoutput>#listgetat([youqueryname].name, 1, " ")#</cfoutput>

Votes

Translate

Translate
Engaged ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

you can treat the name as a space-delimited list and use the ListGetAt function to get the first element of the list:

<cfoutput>#listgetat([youqueryname].name, 1, " ")#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

Thanks, works like a charm!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 20, 2006 Dec 20, 2006

Copy link to clipboard

Copied

LATEST
Just to spread the knowledge of CF functions you could have also used
the listFirst function which returns the first element of a list.

<cfoutput>#listFirst([youqueryname].name," ")#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation