Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

modify display depending on data

New Here ,
Sep 29, 2011 Sep 29, 2011

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?

724
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 04, 2011 Oct 04, 2011

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.

Translate
Advocate ,
Sep 29, 2011 Sep 29, 2011

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2011 Oct 01, 2011

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")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 04, 2011 Oct 04, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 04, 2011 Oct 04, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources