Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using rereplace to force part of a string to uppercase

Posted on 2006-06-29
12
Medium Priority
?
239 Views
Last Modified: 2013-12-24
i have a string
"My company SomeName 1234 Steeles Avenue West Concord ON l4k 3s2"

i need to make the l4k 3s2 to upper case, it will always be in the format a9a 9a9

been trying this,
#myString#<br>
#refindnocase("[a-z]\d[a-z]\s?\d[a-z]",myString)#<br>
#rereplacenocase(mystring,"[a-z]\d[a-z]\s?\d[a-z]","\U\1\d\2")#<br>
#mystring#<br>

but no luck

TIA
0
Comment
Question by:James Rodgers
  • 5
  • 4
12 Comments
 
LVL 36

Expert Comment

by:SidFishes
ID: 17011198


try #ucase(mystring)#
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 17011806
no, i only want part of the string in uppercase not the whole thing
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 17011987
there's probably a cleaner way but

<cfset var = refindnocase("([A-Z]\d[A-Z] \d[A-Z]\d)",myString)>
<!--- get the first part of string up to the postcode --->
<cfset repl = Left(mystring,var-1)>
<cfset myNewstring = replace(mystring, repl, "")>
<cfset MyNewString = Left(myNewString, 7)>
#ucase(MyNewString)#


0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 25

Author Comment

by:James Rodgers
ID: 17012034
yea, doing something similar now, but was looking for a cleaner/more efficient method
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 17012045
This will find the PC in the middle of a string (if it was always at the end it would be easier

<cfset mystring = "My Postal Code is t3r 3t5 where i live">

<cfset var = refindnocase("([A-Z]\d[A-Z] \d[A-Z]\d)",myString)>
<!--- get the first part of string up to the postcode --->
<cfset repl = Left(mystring,var-1)>
<cfset rightOf = right(mystring,var-6)>
<cfset myNewstring = replace(mystring, repl, "")>
<cfset MyNewString = Left(myNewString, 7)>
<cfset myFinalString = repl & ucase(MyNewString) & rightof>

#myFinalString#
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 17012363
this is what i'm doing now
#replace(left(myString,refindnocase("[a-z]\d[a-z]\s?\d[a-z]",myString)-1), chr(10),'<br>','all')##ucase(mid(myString,refindnocase("[a-z]\d[a-z]\s?\d[a-z]",myString),255))#
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 1000 total points
ID: 17012439
tidy   but problem with that is if your string is

<cfset mystring = "my postal code is f4f 3f3 what is yours">

your result is

my postal code is F4F 3F3 WHAT IS YOURS

of course if PC is always at the end a simple

#ucase(right(mystring, 7))#

works

0
 
LVL 25

Author Comment

by:James Rodgers
ID: 17012477
yea, i know, stll want to get it working with a regex, would be better, so right now i'm assuming that it is the last thing in the string
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 17256527

"so right now i'm assuming that it is the last thing in the string"

#ucase(right(mystring, 7))# works just fine however it isn't using rereplace so maybe it isn;t the answer (although it -is- an answer)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question