php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18714 preg_match requires double-escape for \ and /
Submitted: 2002-08-02 17:19 UTC Modified: 2002-08-02 19:03 UTC
From: dhoherd at actiontec dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.2.2 OS: rh7.3 / win2kpro
Private report: No CVE-ID: None
 [2002-08-02 17:19 UTC] dhoherd at actiontec dot com
using preg match to search for \ or / requires you to double-escape the characters.

"/[\\\\\/]/" - works fine and mathches either \ or /.
"/[\\\/]/" - doesn't work, gives the error "Warning: Unknown modifier ']'"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-02 17:20 UTC] dhoherd at actiontec dot com
using preg_match(), and possibly others that i haven't tested, to search for \ or / requires you to double-escape the
characters.

"/[\\\\\/]/" - works fine and mathches either \ or /.
"/[\\\/]/" - doesn't work, gives the error "Warning: Unknown modifier
']'"
 [2002-08-02 19:03 UTC] sniper@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. 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

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC