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

Function returning extra whitespace

Guest
Aug 11, 2008 Aug 11, 2008
I created a function to strip all non-numeric characters from a string and format the phone number in a specific manner, but the string that is returned has a <space> at the beginning of the number every time. Using TRIM() does not need to remove the extra whitespace. Any ideas?
TOPICS
Getting started
713
Translate
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
Engaged ,
Aug 11, 2008 Aug 11, 2008
I don't see you using trim anywhere? Also, what is the number you are passing in your test?
Translate
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
Engaged ,
Aug 11, 2008 Aug 11, 2008
add output="false" to your cffunction declaration
Translate
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
Engaged ,
Aug 11, 2008 Aug 11, 2008
Sorry I didn't notice that straight away but I have been putting that in by default for so long that I forgot about that behaviour!
Translate
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
Guest
Aug 11, 2008 Aug 11, 2008
I had used TRIM() in these 2 scenarios:

<cfreturn trim(tmpPhone)>

and when calling the function:

#TRIM(FormatPhone(varaible))#

The value of "variable" may be "123-456-7890"
Translate
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
Guest
Aug 11, 2008 Aug 11, 2008
I guess setting output="no" worked even though I swear I tried that already... thanks!
Translate
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
Engaged ,
Aug 11, 2008 Aug 11, 2008
LATEST
Basically if you do not put output="false" then it will leave the white space for the the cftags it has removed to leave the result. It is a crap behaviour and is there because functions can output text without having to return it. It is a crap behaviour IMO however some people want to use it that way.

I wish cffunction had output="false" as default instead of the other way round, but that would be beginning of a long wish-list!
Translate
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