On 15 March 2011 12:41, Ben Schmidt wrote:
> static $re = '/(^|[^])\'/';
>>>
>>> Did no one see why the regex was wrong?
>
> I saw what the regex was. I didn't think like you that it was 'wrong'.
>
> Once you unescape the characters in the PHP single-quoted string above
> (where two bac
On 03/15/11 12:41, Ben Schmidt wrote:
> [snip]
>
> Hope this helps,
>
> Ben.
As an outsider in this discussion, I'd just like to applaud you for one
of the best, in-depth, most patient and most thorough explanations I
have ever seen on a mailing list.
Dave
--
PHP Internals - PHP Runtime Develo
Now, here is a pattern which actually means "a quote which doesn't
already have a backslash before it" which is achieved by means of a
lookbehind assertion, which, even when searching the string after the
first match, "'str", still 'looks back' on the earlier part of the
string to recognise the se
static $re = '/(^|[^])\'/';
Did no one see why the regex was wrong?
I saw what the regex was. I didn't think like you that it was 'wrong'.
Once you unescape the characters in the PHP single-quoted string above
(where two backslashes count as one, and backslash-quote counts as a
quote)
On 15 March 2011 10:32, Richard Quadling wrote:
> On 14 March 2011 20:36, Hannes Landeholm wrote:
>> What is more likely to be wrong? Your understanding of a specific
>> regex pattern (which happens to be full of escapes making it
>> incredibly hard to read) or the implementation of preg_replace?
On 14 March 2011 20:36, Hannes Landeholm wrote:
> What is more likely to be wrong? Your understanding of a specific
> regex pattern (which happens to be full of escapes making it
> incredibly hard to read) or the implementation of preg_replace?
>
> ~Hannes
>
> On 14 March 2011 16:18, Martin Scotta
What is more likely to be wrong? Your understanding of a specific
regex pattern (which happens to be full of escapes making it
incredibly hard to read) or the implementation of preg_replace?
~Hannes
On 14 March 2011 16:18, Martin Scotta wrote:
>
> I chose the simplest example to show the preg_re
On 15/03/11 5:38 AM, Ben Schmidt wrote:
On 15/03/11 2:18 AM, Martin Scotta wrote:
I chose the simplest example to show the preg_replace behavior,
You've GOT to be kidding. The SIMPLEST?!
How about an example that doesn't require escaping ALL the interesting
characters involved?
Here's a modi
On 15/03/11 2:18 AM, Martin Scotta wrote:
I chose the simplest example to show the preg_replace behavior,
You've GOT to be kidding. The SIMPLEST?!
How about an example that doesn't require escaping ALL the interesting
characters involved?
Here's a modified version that I think it quite a bit
On 14 March 2011 15:18, Martin Scotta wrote:
> function test($str) {
> static $re = '/(^|[^])\'/';
> static $change = '$1\\\'';
>
> echo $str, PHP_EOL,
> preg_replace($re, $change, $str), PHP_EOL, PHP_EOL;
> }
>
> test("str '' str"); // bug?
> test("str \\'\\' str"); // ok
> t
I chose the simplest example to show the preg_replace behavior, there are
better (and safer) ways to scape slash characters.
Anyways, *is this the expected preg_replace behavior?*
Martin
11 matches
Mail list logo