Avatar of earwig75
 asked on

Need help with Cold Fusion "Replace"

I have something like the below code. I have a variable called "monitor" that will contain a text string.  Sometimes this string will have something like ABC 1234 in it... If it does I want it stripped out/replaced with nothing. So, if my variable is "monitor ABC 7777" I just want it converted to "monitor". The ABC remains the same but the numbers can possibly be different.

Can someone help? Does what I have below look correct?

<cfhttpparam name="SendMonitor" type="CGI" value="#replace(URL.Monitor,"ABC %%%%","","all")#">

Open in new window

Microsoft SharePointColdFusion Language

Avatar of undefined
Last Comment

8/22/2022 - Mon

actually you can use the listFirst function by treating the space as a delimiter (as long as that is consistent)

<cfset vMonitor = listfirst(url.monitor, " ")>

if that doesn't work, you might want to look at using REReplaceNoCase which uses regex (which I suck at so I might not be able to help if that's the case)

Sometimes my string will be something like "Hello the device type is monitor ABC 7777 and it is blue".

But sometimes it will be "Hello the device type is desktop ABC 7878 and it is blue...

I would want either one of those converted to:  "Hello the device type is monitor and it is blue." Or... desktop etc...

Basically anytime ABC **** shows up in a string I want it stripped out - without it mattering what is before or after it.


Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes