?
Solved

using rereplace to force part of a string to uppercase

Posted on 2006-06-29
12
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…
Suggested Courses

718 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