coldfusion concatenate strings

I want to grab a url like this one:
http://mydomain.com/12543/mystreetnumber-streetname.html
and 301 redirect it to
http://mydomain.com/A12543/mystreetnumber-streetname.html

I'm trying to figure out how to prepend the A to the  cgi.script_name

Here is what I have tried:

<cfset mlsidentifier = "A">
<cfset test = mlsidentifier & cgi.script_name>


but that just outputs:    
A/12543/mystreetnumber-streetname.html

where I need
A12543/mystreetnumber-streetname.html

Is it possible to prepend a character to the cgi.script_name?

Any help appreciated!
Bang-O-MaticAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
A simple regex like this might do it:

<!--- If the 1st character is "/", replace it with "/A" --->
<cfset oldPath = "/12543/mystreetnumber-streetname.html">
<cfset newPath = reReplace( oldPath, "^(/)", "\1"& mlsidentifier )>
<cfoutput>#newPath#</cfoutput>

You could also use list functions.  Though if the script_name path can vary from what you posted, might want to add some validation to handle unexpected case.
0
_agx_Commented:
Something like this should work as well. Just throw in validation in case of an empty path

     <cfset oldPath = "/12543/mystreetnumber-streetname.html">
     <cfset newPath = listSetAt(oldPath, 1, mlsidentifier & listFirst(oldPath, "/"), "/")>
     <cfoutput>#newPath#</cfoutput>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bang-O-MaticAuthor Commented:
Hi _agx_ I havent had a chance to test this, but yes these are all dynamic URL's that I want to redirect.

Looking at your code sample:  oldpath = cgi.script_name

So this should work, correct?
<cfset mlsidentifier = "A">
<cfset oldPath = cgi.script_name>
<cfset newPath = listSetAt(oldPath, 1, mlsidentifier & listFirst(oldPath, "/"), "/")>
     <cfoutput>#newPath#</cfoutput>

Thanks for the help on a Saturday!!
0
_agx_Commented:
Sorry, I was away from the gadgets for a while :)

I can't test it right now, but that looks fine. (I just hard coded the path for demo purposes). Though you may want to add some validation for unexpected paths.
0
Bang-O-MaticAuthor Commented:
Thanks _agx_! worked perfect!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.