----- Original Message -----
From: "Deniz Dizman (BST UGB)" <DENIZ.DIZMAN@xxxxxxxxxxxxx>
To: "C.R.Vegelin" <cr.vegelin@xxxxxxxxx>; "php-general@xxxxxxxxxxxx"
<php-general@xxxxxxxxxxxxx>
Sent: Thursday, September 20, 2007 12:25 PM
Subject: RE: highlighting searchterms as bold text
you probably have some characters before/after the phrase that prevents
the match.
This should do it: (i hope)
/(\S|\s)*\bethyl\b(\S|\s)*/i
--
dd
-----Original Message-----
From: C.R.Vegelin [mailto:cr.vegelin@xxxxxxxxx]
Sent: Thursday, September 20, 2007 3:09 PM
To: Deniz Dizman (BST UGB); php-general@xxxxxxxxxxxx
Subject: Re: highlighting searchterms as bold text
----- Original Message -----
From: "Deniz Dizman (BST UGB)" <DENIZ.DIZMAN@xxxxxxxxxxxxx>
To: "C.R.Vegelin" <cr.vegelin@xxxxxxxxx>; "php-general@xxxxxxxxxxxx"
<php-general@xxxxxxxxxxxxx>
Sent: Thursday, September 20, 2007 11:29 AM
Subject: RE: highlighting searchterms as bold text
thats odd because the regex passes when I test it with this
online tool:
http://samuelfullman.com/team/php/tools/regular_expression_tes
ter_p2.php
--
dd
> -----Original Message-----
> From: C.R.Vegelin [mailto:cr.vegelin@xxxxxxxxx]
> Sent: Thursday, September 20, 2007 1:59 PM
> To: Deniz Dizman (BST UGB); php-general@xxxxxxxxxxxx
> Subject: Re: highlighting searchterms as bold text
>
>
> ----- Original Message -----
> From: "Deniz Dizman (BST UGB)" <DENIZ.DIZMAN@xxxxxxxxxxxxx>
> To: "C.R.Vegelin" <cr.vegelin@xxxxxxxxx>; "php-general@xxxxxxxxxxxx"
> <php-general@xxxxxxxxxxxxx>
> Sent: Thursday, September 20, 2007 10:38 AM
> Subject: RE: highlighting searchterms as bold text
>
>
> try /^ethyl/i
> what you want is ignore case and pattern begins with
>
> --
> dd
>
> > -----Original Message-----
> > From: C.R.Vegelin [mailto:cr.vegelin@xxxxxxxxx]
> > Sent: Thursday, September 20, 2007 1:31 PM
> > To: php-general@xxxxxxxxxxxx
> > Subject: highlighting searchterms as bold text
> >
> > Hi everyone,
> >
> > I want to highlight (bold) searchterms in text.
> > For example, for all words starting with "ethyl":
> > a) replace "ethyl" by "<b>ethyl</b>"
> > b) replace "Ethyl" by "<b>Ethyl</b>"
> > c) replace "ethylene" by "<b>ethylene</b>"
> > d) but not "methyl" by "<b>methyl</b>"
> >
> > Now I use:
> > $patterns[0] = "/ethyl/";
> > $replacements[0] = "<b>ethyl</b>";
> > $text = preg_replace($patterns, $replacements, $text);
> >
> > This works for a) and c), but not for b) and d).
> > Any idea how to do this ?
> >
> > TIA, Cor
> >
>
> Thanks Deniz,
>
> I tried pattern /^ethyl/i but this does not highlight anything.
> I also tried pattern /ethyl/i and this highlights all, but
> also methyl ...
> Any suggestion ?
>
> Cor
>
Hi Deniz,
I tried the referred regex tool as well,
and I get Bad Result for /^ethyl/i
and Good Result for /ethyl/i
Cor
Hi Deniz, Edward, Mike,
Thanks for your suggestions.
Deniz,
pattern /(\S|\s)*\bethyl\b(\S|\s)*/i
makes from any line containing ethyl, such as
Undenatured ethyl alcohol
lines containing only: >ethyl
Edward,
pattern /(\s|>)ethyl(\s|<)/i
makes from: Undenatured ethyl alcohol
Undenaturedethylalcohol (stripping spaces).
I will take a look at http://suda.co.uk/projects/SEHL/.
Mike,
the \W character
makes from Undenatured ethyl alcohol
Undenaturedethylalcohol (stripping spaces).
The \b character makes:
Undenatured ethyl alcohol (okay)
the word methyl is unchanged (okay)
but ethylene keeps also unchanged ...
Thanks anyway !
Cor
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php