Ask a Question related to Macromedia ColdFusion, Design and Development.
-
d.acha #1
Repetitive white spaces in string
I want to prevent if visitor type more than 1 white space between two words.
For example (I will use underscore "_" instead of white space " " here,
because You cannot see repetitive white spaces, only in source):
let's say, the string visitor will type in the input form field is:
"macromedia___coldfusion_mx_____7"
I want to replace all needless white spaces (or underscores here) and I want
to get following string "macromedia_coldfusion_mx_7" - between two words I want
to have only one white space
have you any ideas?
regards,
d.acha
d.acha Guest
-
How do I set string to null or all spaces
:confused; I have a form I am submitting to itself. I want to the text area on the screen to stay until all error messages are cleared, so I stored... -
replace spaces with 0's in a string
I have a string like this '00023MJKOP16598 09 00' I need to replace spaces in this string with zeros so that the spaces are gone. So it would... -
Scanned Graphics / Screen Shots / White Spaces
I am using an IBM Windows XP / Microsoft Office 2003 with 504 RAM. I don't have CorelDRAW to copy my screen shots into. So therefore, I paste into... -
Adding white spaces
Hi All, I have a file looking like (where \n is new line): blabla\n blablablablablabla\n blablablablablablablablablabla\n blabla\n but I... -
To count a number of lines in C++ or Java or ASCII files by exluding white spaces and comments
Hi all, We have huge files in Java and C++ and I need to count the total number of lines in each of them by excluding white spaces (from the... -
nancy.debnam #2
Re: Repetitive extra blank spaces in string
Use REReplace
#reReplace(testString,"\s+"," ","All")#
This a regular expression replace.
The first param is the string that the extra white space is to be stripped
from.
The second param is a regular expression which you are looking to replace.
The regular expression "\s+" means one or more white space characters.
The third param is the string that you will be putting in place of the
previous.
The fourth param is optional, "All" indicates that you would like to replace
all instances of the reg expression. The default for this param is "One" which
will replace only the first occurance.
The code below will allow you to see it in action.
<cfset testString = "my cold fusion server">
<pre>
#testString#
#reReplace(testString,"\s+"," ","All")#
</pre>
Best of Luck,
Nancy
nancy.debnam Guest
-
d.acha #3
Re: Repetitive extra blank spaces in string
thanks nancy,
that's that!
Additionally, I have surrounded Your code with one Trim function and I have
exactly what I have meant.
Trim(reReplace(testString,"\s+"," ","All"))
Bye the way, You have exactly typed what I have asked, but I need that Trim
more.
Thanks a lot
dacha
d.acha Guest



Reply With Quote

