php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27949 preg_match cant match ?
Submitted: 2004-04-10 21:11 UTC Modified: 2004-04-11 05:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: drew at corrupt dot co dot nz Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.5 OS: FreeBSD 4.9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: drew at corrupt dot co dot nz
New email:
PHP Version: OS:

 

 [2004-04-10 21:11 UTC] drew at corrupt dot co dot nz
Description:
------------
I am trying to match a question mark in PHP using preg_match() with the following attempt's described in the code section.

Neither work, while following documentation examples.

Reproduce code:
---------------
// String:
$line = "This is pretty much a [url=\"http://www.wiki.org/?WhatIsAWIki\"]Wiki[/url] but with a twist of [BBCode] and a few other site specific [Hacks]";

// Attempt #1:
preg_match_all("/\[(\/?[\w\d\-\_]+(=\"[\w\d\S\s\?]+?\")?)\]/",$line,$parse);

print_r($parse);

// Attempt #2:
preg_match_all("/\[(\/?[\w\d\-\_]+(=\"[\w\d\S\s\\\?]+?\")?)\]/",$line,$parse);

print_r($parse);

Expected result:
----------------
I expected that the values

"url=http://www.wiki.org/?WhatIsAWIki" and "http://www.wiki.org/?WhatIsAWIki" would be picked up from the regex into $parse.

It works with the following PERL one liner:

perl -e '$string = "This is pretty much a [url=\"http://www.wiki.org/?WhatIsAWIki\"]Wiki[/url] but with a twist of [BBCode] and a few other site specific [Hacks]"; @match = $string =~ m/\[(\/?[\w\d\-\_]+(=\"[\w\d\S\s\?]+?\")?)\]/; print "Match: " . join(",",@match) . "\n"'

Match: url="http://www.wiki.org/?WhatIsAWIki",="http://www.wiki.org/?WhatIsAWIki"

Actual result:
--------------
Matches nothing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-11 00:07 UTC] sniper@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.

RTFM: You need to use double backslashes to quote stuff..

 [2004-04-11 05:44 UTC] drew at corrupt dot co dot nz
I tried double backslashing aswel.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC