Re: regular expression problem
- From: David Haynes <david.haynes2@xxxxxxxxxxxx>
- Date: Wed, 24 May 2006 09:54:00 -0400
condor wrote:
I want to select a text between square brackets. As it may containSomething like this?
accents and punctuation I try to use the negation:
"\[([^\]])\]"
However, this does not work and the problem is with the closing square
bracket ("]").
My questions are:
- Is "\]" some reserved sequence with a special meaning.
- if so, how can I work around that and still get functionality I want
<?php
$tests[] = "[this is a test]";
$tests[] = "[Who's life is it anyway?]";
$pat = "[[](.*)[]]";
foreach( $tests as $test ) {
$matched = ereg($pat, $test, $match);
printf("test = '%s', pattern = '%s', match = '%s'\n",
$test, $pat, $match[1]);
}
?>
-david-
.
- Follow-Ups:
- Re: regular expression problem
- From: condor
- Re: regular expression problem
- References:
- regular expression problem
- From: condor
- regular expression problem
- Prev by Date: regular expression problem
- Next by Date: Re: regular expression problem
- Previous by thread: regular expression problem
- Next by thread: Re: regular expression problem
- Index(es):
Relevant Pages
|