Solved

using rereplace to force part of a string to uppercase

Posted on 2006-06-29
12
230 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
Comment Utility


try #ucase(mystring)#
0
 
LVL 25

Author Comment

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

Expert Comment

by:SidFishes
Comment Utility
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
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
yea, doing something similar now, but was looking for a cleaner/more efficient method
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 36

Expert Comment

by:SidFishes
Comment Utility
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
Comment Utility
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 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility

"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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now