Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace beginning date value on update of form 1

Status
Not open for further replies.

toyt78

Technical User
Apr 5, 2005
125
US
I have a field value update information box where it sometimes looks like this:
Code:
(08/12/05) stuff here etc...
Date will always be in the dd/mm/yy format.

I need to create a condition to check if the date is the first part of the value and replace or reg expression to eliminate the date part each time someone updates this information so it look like this if they add information to the field value:
Code:
stuff here etc...MY ADDITION HERE

Here is my attempt that is not working:
Code:
<--- Check if date format (mm/dd/yy) is beginning part of form value , if it is then eliminate it  --->
<cfif REFind("^\(\d{2}/\d{2}/\d{2}\)", myField) is 0>
     <REReplaceNoCase(form.myfield,"^\(d{2}/\d{2}/\d{2}\)">
</cfif>


 
A few problems:

1)
<cfif REFind("^\(\d{2}/\d{2}/\d{2}\)", myField) is 0>
is 0 means not found

2)
<REReplaceNoCase(form.myfield,"^\(d{2}/\d{2}/\d{2}\)">
doesn't do anything. you have to set the new value to something.
3) Your replace regex was different from the find regex, they should be the same...

Code:
<cfset mystring = "(08/25/05) this is a comment">
<!--- Check if date format (mm/dd/yy) is beginning part of form value, if it is then eliminate it  --->
<cfset place = REFind("^\(\d{2}/\d{2}/\d{2}\)", mystring)>
<cfif REFind("^\(\d{2}/\d{2}/\d{2}\)", mystring) gt 0>
     <cfset myString = REReplaceNoCase(mystring,"^\(\d{2}/\d{2}/\d{2}\)","")>                               	
</cfif>
<cfoutput>#place#<br>#myString#</cfoutput>

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top