php help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I need some php help.

I need to replace â followed by two unknown characters with an
empty string.

I tried this, but it's not quite right:

$newstring=preg_replace ("/â??/i", "",$newstring);

Any ideas?

Re: php help

Quoted text here. Click to load it

You didn't specify what these unknown characters should be.
I am guessing non-whitespace. In that case this would be appropriate:

$newstring=preg_replace ('/â\S\S/i', '',$newstring);

So that would match:

But wouldn't match:
â asdasd

âa sdasd

Note the "single" quotes (apostrophe) instead of your double quotes (that
don't need to escape backslash).

If you want to match anything then use:
$newstring=preg_replace ('/â../i', '',$newstring);

That would match any case of the above.

Re: php help

El 01/09/2011 0:23, bob escribió/wrote:
Quoted text here. Click to load it

"Not quite right". Nice description. As useful as "Does not work" :)

Quoted text here. Click to load it

The "?" symbol means "any character" in Windows wildcards but not in
regular expressions. You want "." instead:

var_dump( preg_replace ('/&acirc;../i', '', '&acirc;abKeep Me!') );

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor satinado:

Site Timeline