php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28138 Error in Backslashing
Submitted: 2004-04-24 22:18 UTC Modified: 2004-04-24 22:29 UTC
From: info at giggygsk dot de Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.3.4 OS: Win32
Private report: No CVE-ID: None
 [2004-04-24 22:18 UTC] info at giggygsk dot de
Description:
------------
Hi.
If you build a Regular Ex. like this: /([^\\]\|\*\|)/ there will be come an error, because 'PHP' think I mean with [^\\] I want backslashing the ']' so it will be do a error, because he want an ']' because it backslashed ']'. But I want the char '\', because thats a Specialchar ;-). 

Reproduce code:
---------------
<?php

// Result in Perl : Test1 - Test2\|*|Test3
$string = "Test1|*|Test2\|*|Test3";

$split = preg_split("/([^\\]\|\*\|)/", $string);

?>


Expected result:
----------------
Warning: Compilation failed: missing terminating ] for character class at offset 17 in D:\Apache2\htdocs\GG_Shoutbox\msg.class.php on line 17


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-24 22:29 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

You need to double escape it, or use single quotes.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 18:01:38 2019 UTC