Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
coolidge #1
trimming a string
I'm generating strings dynamically in my application, and they look something
lie this:
0 0 0 435921014 0 0 0 0
What I want to do is trim off all the characters before the first '4' and
after the second '4'. Would anyone be able to assist me with the syntax for
that? Thank you...
coolidge Guest
-
trimming a string either side of a keyword
i want to trim the search results 100 chars EITHER side of the word. BUT that word might appear as the first word in results or the last in which... -
trimming arcs/ellipses
I have some arc and ellipse geometrys that I need to trim but can not figure out how. The ellipse I had to draw way out from the end point to get my... -
Trimming Whitespace
I have a movie that imports an avi file into a cast member through script. The avi file has lots of whitespace around it. Unfortunately, when... -
Trimming Blank Spaces in String
You can use the VB.NET function RTRIM. -- I hope this helps, Steve C. Orr, MCSD http://Steve.Orr.net "Temp" <tempmail@temp.com> wrote in... -
trimming a variable.
I need to trim a variable to have everything after 4 chars in a string. IE: var_temp = 200:16:1234567890 i want everything after 200: to be... -
allen@oysterweb.com #2
Re: trimming a string
<cfset Test = "0 0 0 435921014 0 0 0 0">
<cfset GoodString = #Mid(Test, #findnocase("4",Test)#+1,
#findnocase("4",Test,#findnocase("4",Test)#+1)# -
#findnocase("4",Test)#-1)#>
That should do it.
allen@oysterweb.com Guest
-
TurboMini #3
Re: trimming a string
Use the mid() function:
mid(string, start, count)
Will you always have zeros at the beginning and end, or will they be varying
digits with consistent spacing in between? That will determine how to trim the
string.
TurboMini Guest
-
Dan Bracuk #4
Re: trimming a string
First, replace all the instances of "0 " (zero space) with ""
Then replace all the instances of " 0" (space zero) with "".
Originally posted by: coolidge
I'm generating strings dynamically in my application, and they look something
lie this:
0 0 0 435921014 0 0 0 0
What I want to do is trim off all the characters before the first '4' and
after the second '4'. Would anyone be able to assist me with the syntax for
that? Thank you...
Dan Bracuk Guest
-
mxstu #5
Re: trimming a string
As TurboMini mentioned, if the value will always be in the 4th position and
each set of numbers will always be separated by a space, simply use the
listGetAt() function with a space (chr(32) as the delimiter.
<cfset yourValue = "0 0 0 435921014 0 0 0 0">
<cfoutput>#ListGetAt(yourValue, 4, chr(32))#</cfoutput>
mxstu Guest
-
Stressed_Simon #6
Re: trimming a string
I would personally use regEx as it is cleaner:-
<cfscript>
original = "0 0 0 435921014 0 0 0 0";
result = reReplace(original, "(0\s0\s0\s)|(\s0\s0\s0\s0)", "", "all");
writeoutput("#wang#<br />#result#");
</cfscript>
Stressed_Simon Guest
-
mxstu #7
Re: trimming a string
Just to be safe, you might want to structure the regular expresssion to search
for multiple spaces between the zeros. Something like:
<!--- more than one space in between first and second zero --->
<cfset original = "0 0 0 435921014 0 0 0 0">
<cfoutput>
new #reReplace(original, "(0\s+0\s+0\s+)|(\s+0\s+0\s+0\s+0)", "", "all")#<br>
old #reReplace(original, "(0\s0\s0\s)|(\s0\s0\s0\s0)", "", "all")#<br>
mxstu Guest



Reply With Quote

