Solved

using rereplace to force part of a string to uppercase

Posted on 2006-06-29
12
231 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
 
LVL 25

Author Comment

by:James Rodgers
ID: 17012034
yea, doing something similar now, but was looking for a cleaner/more efficient method
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 250 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

16 Experts available now in Live!

Get 1:1 Help Now