Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3040 > unrolled thread
| Started by | bob <bob@coolgroups.com> |
|---|---|
| First post | 2011-08-31 15:23 -0700 |
| Last post | 2011-09-01 10:44 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
php help bob <bob@coolgroups.com> - 2011-08-31 15:23 -0700
Re: php help "A" <a@a.a> - 2011-09-01 00:48 +0200
Re: php help "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-09-01 10:44 +0200
| From | bob <bob@coolgroups.com> |
|---|---|
| Date | 2011-08-31 15:23 -0700 |
| Subject | php help |
| Message-ID | <a69ee922-56bf-4e13-bc28-8a6db69c4701@o26g2000vbi.googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | "A" <a@a.a> |
|---|---|
| Date | 2011-09-01 00:48 +0200 |
| Message-ID | <j3mdp5$rve$1@gregory.bnet.hr> |
| In reply to | #3040 |
> $newstring=preg_replace ("/â??/i", "",$newstring);
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:
âabcer
But wouldn't match:
â asdasd
or...
â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.
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2011-09-01 10:44 +0200 |
| Message-ID | <j3nglv$4vk$1@dont-email.me> |
| In reply to | #3040 |
El 01/09/2011 0:23, bob escribió/wrote:
> 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:
"Not quite right". Nice description. As useful as "Does not work" :)
>
>
> $newstring=preg_replace ("/â??/i", "",$newstring);
The "?" symbol means "any character" in Windows wildcards but not in
regular expressions. You want "." instead:
<?php
var_dump( preg_replace ('/â../i', '', 'âabKeep Me!') );
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web