Re: Write multiple backslashes

From: Date: Wed, 08 Mar 2017 13:58:38 +0000
Subject: Re: Write multiple backslashes
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-326017@lists.php.net to get a copy of this message
On Wed, Mar 8, 2017 at 8:40 AM, Danny <mynixmail@gmail.com> wrote: > As a matter of interest I got it solved using 8 backslashes ... one would > think > that 1 backlash will escape 1 more backlash, but it doesn't. Somehow 8 > backlashes did the job ... don't ask me how ... > > $IGNORE_TMP=^(\\\\\\\\*.*\\\\\\\\*)$ > > Thank you for everyone's input ... > > > > > I'm no regard expert but don't you have to escape it for each one? > > Something like $second_rexexp = "ignore_tmp=^(\\\\*.*\\\\*)$"; > > > > I could be way off base though... > > > > > > Yes that's true but only because it is a double quoted string, meaning > > backslashes are treated as escape sequences. > > > > You could also just use a single quoted string. > > > > $second_regexp = 'IGNORE_TMP=^(\\*.*\\*)$'; > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You do need 4 slashes for each slash. The way it works is the \\\\ becomes \\ (PHP escapes each \ with \ before sending it to regular expression) then regular expression treats \\ as \. If you were outputting it without sending it to regular expression then \\ would be sufficent.

« previous php.general (#326017) next »