i need some help in rereplace, where i am trying t...
# cfml-beginners
s
i need some help in rereplace, where i am trying to replace required='yes" or required='no' with default='''
d
Can you share some code of what you have tried so far so we can see what you are trying to achieve. https://cfdocs.org/rereplace
s
<cfscript> var param = "required='yes'"; writeOutput(REReplace(param,"required(yes|no)","default=''")) </cfscript>
d
Just change your REReplace to this:
Copy code
REReplace(param,"required='(yes|no)'","default=''");
notice the addition of the ‘=’ after required and the quotes around the (yes|no).
s
no difference, it is still showing me as required='yes' instead of default=''
d
Show your code?
s
here
Copy code
<cfset x = '<cfparam name="holidayID" type="numeric" required="yes">'>
<cfoutput>
#reReplace(x, 'required="(yes|no)"', "default=''", "ALL")#
</cfoutput>
d
It doesn’t seem to like the ‘<cfparam…’ tag being in the string. Can I ask what you are trying to do? Replacing cfparam attributes seems like more of a job for your IDE.
2
s
i am enerating the cfparams with code, so end result is the cfparam and and after that i am just trying to replace the required with default
d
Are you generating the code and writing into a file? Why not amend the code that’s generating the cfparam with the required attribute?
s
amending it before it writes to the file
so the end result is cfparam
d
So, can’t you just change the cfparam anyway before writing to file?
s
that is what i am trying to use rereplace to change required o default but its not working
I am really very skeptical that this is the correct solution to whatever underlying problem you are perceiving you are having though.
d
I was thinking along the same lines. Would be interested to know the ‘why?’ of what is being attempted.