Copy link to clipboard
Copied
Everytime "ok" [a key word] appears, bold the date befor that. Data is coming from a feed.
Example:
Today is March 23, 2010, ok.
Yesterday was January 2, 2009, ok.
Tomorrow will be May 14, 2011, ok.
Result: Today is March 23, 2010, ok.
Yesterday was January 2, 2009, ok.
Tomorrow will be May 14, 2011, ok.
So far...
<CFSET variable = #ReplaceNoCase(variable, "<ok.", "", "ALL")#>
Since date lenght varies each time: Look for two commas and two spaces before the key word and then bold it
Help please?
Did you try the reReplaceNoCase tag? The ",\s*ok" in the first parameter and the ", ok" in the second parameter handle the OK part of your requirement.
Copy link to clipboard
Copied
I would have to do some research but reReplaceNoCase would be your friend:
<cfset variables.str = reReplaceNoCase(variables.str,"((January|February|March|...) (\d){1,2}, (\d){4})),\s*ok","<strong>\\1</strong>, ok","ALL") />
I know this is probably not 100%, but it should be close. (and the ... needs to be expanded to all the months)
Copy link to clipboard
Copied
Steve Sommers wrote:
I would have to do some research but reReplaceNoCase would be your friend:
<cfset variables.str = reReplaceNoCase(variables.str,"((January|February|March|...) (\d){1,2}, (\d){4})),\s*ok","<strong>\\1</strong>, ok","ALL") />
I know this is probably not 100%, but it should be close. (and the ... needs to be expanded to all the months)
Just a little tweak:
reReplacenocase(variables.str,"((January|February|March|April|May|June|July|August|September|October|November|December) (\d){1,2}, (\d){4}),\s*ok","<strong>\1</strong>, ok","ALL")
Copy link to clipboard
Copied
I must apologize, as I was not clear in my question. Actually in the original feed, there are many dates in a paragraph. I only need to bold the date which is followed by a keyword.
Example. This is the first date, January 1, 1980. This is the second date, March 2, 1990. This is another date, May 1, 2000, OK. This is the last date, June 1, 2010.
“OK” being my keyword, the date before “OK” has to be bolded.
So I need to start by looking for the keyword.
Then figure out how many characters to move back and then bold that string.
Copy link to clipboard
Copied
Did you try the reReplaceNoCase tag? The ",\s*ok" in the first parameter and the ", ok" in the second parameter handle the OK part of your requirement.