Re: eregi_replace returns only lowercase



Bob schreef:
Erwin Moller
<Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx> wrote in
news:490ece9d$0$184$e4fe514c@xxxxxxxxxxxxxx:

Bob schreef:
Alex Eiswirth <Alex.Eiswirth@xxxxxxxxx> wrote in
news:937a06ac-e448-4a2e-9587-15a3bbca1ebc@xxxxxxxxxxxxxxxxxxxxxxxxxxx:

On Nov 3, 10:30 am, Bob <b...@xxxxxxxxx> wrote:
Hi,

Maybe this problem has already been mentionned, but I am new to
this grou
p,
so here we go.

$string = "This is for ABC only"

$new = (eregi_replace('ABC','<b>ABC</b>',$string));

print $new geeft nu
This is for <b>abc</b> only
where I would like to see 'abc' in uppercase. I have searched the
interne
t
for the solution, consulted several PHP books, but can not find the
solution. Can anyone help? Thanks.

Bob
Hi Bob,

use ereg_replace instead of eregi_replace.
This function is identical to ereg_replace() except that this
ignores case distinction when matching alphabetic characters.

Alex Eiswirth http://www.eiswirth.de

ereg or eregi makes no difference in the output. In both cases it
returns in lowercase.
Over here:
$string = "This is for ABC only";
echo eregi_replace('ABC','<b>ABC</b>',$string);
gives:
This is for <b>ABC</b> only

AND
$string = "This is for ABC only";
echo ereg_replace('ABC','<b>ABC</b>',$string);
gives:
This is for <b>ABC</b> only

Could you confirm this on your system Bob?
Just use THIS simple codefragmet, and leave the rest of your code out.

Regards,
Erwin Moller

Bob.


Hi Erwin (and others),

You are right, my question in the first place was incorrect. I tried to keep the problem short, but that corrupted the question.

In my example 'ABC' is actually a variable which is filled in by a user in a form. When he fills in 'abc' (lowercase, what most people do with key-words) php returns with 'abc'. When he fills in 'aBc' php returns with 'aBc' etc. Thus, the problem is, that I don't want to care how the user fills in (upper- or lowercase), but I want php to return the original value. Hope this makes the problem more clear.

Part of my script is:

$bkeyword="<font color=\"red\">$keyword</font>";

$occasion = (ereg_replace($keyword,$bkeyword,$occasion));

Bob.

Here is an example.

$string = "This is for AbC only";
echo eregi_replace('(ABC)','<b>\\1</b>',$string);

Read more here about \\1:
http://nl3.php.net/manual/en/function.eregi-replace.php

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
.



Relevant Pages

  • Re: eregi_replace returns only lowercase
    ... where I would like to see 'abc' in uppercase. ... Since you are hard coding "ABC" into the replacement argument, ... key-words) php returns with 'abc'. ... user fills in (upper- or lowercase), but I want php to return the ...
    (comp.lang.php)
  • Re: eregi_replace returns only lowercase
    ... where I would like to see 'abc' in uppercase. ... Since you are hard coding "ABC" into the replacement argument, ... key-words) php returns with 'abc'. ... user fills in (upper- or lowercase), but I want php to return the ...
    (comp.lang.php)
  • Bing Crosby Pro-Am
    ... Remember when Jim McKay and Chris Schenkel covered it every year for ABC? ... When Jack Nicklaus paired with the likes of Jack Lemmon--Arnold Palmer with ... Bob Hope--a young skinny Johnny Miller with Dean Martin? ...
    (rec.sport.golf)
  • Re: eregi_replace returns only lowercase
    ... Erwin Moller ... where I would like to see 'abc' in uppercase. ... returns in lowercase. ... key-words) php returns with 'abc'. ...
    (comp.lang.php)
  • Re: eregi_replace returns only lowercase
    ... Bob wrote: ... $string = "This is for ABC only" ... where I would like to see 'abc' in uppercase. ... before and after your user input, i.e.: ...
    (comp.lang.php)