Solved

using rereplace to force part of a string to uppercase

Posted on 2006-06-29
12
234 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Script 12 174
Asp.net plan security, reliable, stable 2 126
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 108
Internal to DMZ IIS Authentication. 3 24
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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