Beauford wrote:
Here is my rendition of what I think you are looking for.
$str = 'tab()/space( )/[EMAIL PROTECTED]*();:...';
if ( preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $str) ) {
echo 'success';
} else {
echo 'failure';
}
Here is the problem, and it is
Hi Jim,
Thanks for all the help, but where is the link.
Here is a link to a page that has this on it, but with the added '
Plus a link to the source code for it.
Jim
--
PHP General Mailing List (http://www.php.net/) To
unsubscribe, visit: http://www.php.net/unsub.php
--
Beauford wrote:
Hi Jim,
Thanks for all the help, but where is the link.
Here is a link to a page that has this on it, but with the added '
Plus a link to the source code for it.
Jim
--
PHP General Mailing List (http://www.php.net/) To
unsubscribe, visit: http://www.php.net/unsub.php
On Thu, January 25, 2007 9:53 am, Jim Lucas wrote:
http://www.cmsws.com/examples/php/preg_match/example01.php
The \t inside of '' has no special meaning.
So you don't have a TAB character in there.
You need to get \t to mean TAB
Once you do that, you should then escape the $ with \$ instead
Here is my rendition of what I think you are looking for.
$str = 'tab( )/space( )/[EMAIL PROTECTED]*();:...';
if ( preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $str) ) {
echo 'success';
} else {
echo 'failure';
}
Here is the problem, and it is strange. If I enter
At 1/24/2007 01:13 PM, Beauford wrote:
Here is my rendition of what I think you are looking for.
$str = 'tab( )/space( )/[EMAIL PROTECTED]*();:...';
if ( preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $str) ) {
echo 'success';
} else {
echo 'failure';
}
Here is the
2007/1/22, Beauford [EMAIL PROTECTED]:
... much blah blah blah ...
I've probably read 100 pages on this, and no matter what I try it doesn't
work. Including all of what you suggested above - is my PHP possessed?
if(preg_match(/[EMAIL PROTECTED]()*;:_.'/\\ ]+$/, $string)) { gives me
this
# [EMAIL PROTECTED] / 2007-01-23 09:52:17 -0300:
2007/1/22, Beauford [EMAIL PROTECTED]:
PS: Will we be risking going the perl way if we ask that PHP supported
regular expressions natively (I mean: without having to provide them as
strings)?
Yes. I don't know about other people's objections
At 1/23/2007 04:52 AM, Martin Alterisio wrote:
if (preg_match('/[EMAIL PROTECTED]()*;:_.'\\/ ]+$/', $string))
Close but no cigar. Because you're using apostrophe to quote the
expression, PHP interprets the apostrophe inside the character class
as ending the quoted expressions and
if (preg_match('/[EMAIL PROTECTED]()*;:_.'\\/ ]+$/', $string))
Use single quotes and double back-slashes. PHP strings also
have escape sequences that use the back-slash as escape
character, that's why you have to double them. And single
quotes to avoid the $ character interpreted
You need to escape that forward slash in the character class:
preg_match(/[EMAIL PROTECTED]()*;:_.'\/
Also, you've got only two backslashes in your char class. PHP is
reducing this to a single backslash before the space character. I
think you intend this to be two
if (preg_match('/[EMAIL PROTECTED]()*;:_.'\\/ ]+$/', $string))
Here is my rendition of what I think you are looking for.
$str = 'tab()/space( )/[EMAIL PROTECTED]*();:...';
if ( preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|', $str) ) {
echo 'success';
} else {
Beauford wrote:
You need to escape that forward slash in the character class:
preg_match(/[EMAIL PROTECTED]()*;:_.'\/
Also, you've got only two backslashes in your char class. PHP is
reducing this to a single backslash before the space character. I
think you intend this to be
At 1/23/2007 09:50 AM, Beauford wrote:
preg_match(/[EMAIL PROTECTED]()*;:_.'\/ ]+$/, $string)
On top of this, every time a ' is entered it gets preceded by \. If I just
check for the characters like below that doesn't happen. Totally confused.
if(preg_match(/^[-A-Za-z0-9_.' ]+$/,
You don't need to escape the apostrophe if the pattern isn't
quoted with apostrophes in PHP or delimited by apostrophes in
the PREG pattern. But generally there's no harm in escaping
characters unnecessarily; it just makes for messier code.
Here is a simple test of the regexp I
At 1/22/2007 03:04 PM, Beauford wrote:
I'm trying to get this but not quite there. I want to allow the following
characters.
[EMAIL PROTECTED]()*;:_.'/\ and a space.
Is there a special order these need to be in or escaped somehow. For
example, if I just allow _' the ' is fine, if I add the
-Original Message-
From: Paul Novitski [mailto:[EMAIL PROTECTED]
Sent: January 22, 2007 6:58 PM
To: PHP
Subject: Re: [PHP] preg_match problem
At 1/22/2007 03:04 PM, Beauford wrote:
I'm trying to get this but not quite there. I want to allow the
following characters
At 1/22/2007 04:56 PM, Beauford wrote:
I've probably read 100 pages on this, and no matter what I try it doesn't
work. Including all of what you suggested above - is my PHP possessed?
if(preg_match(/[EMAIL PROTECTED]()*;:_.'/\\ ]+$/, $string)) { gives me
this error.
Warning: preg_match()
2007/1/20, Arpad Ray [EMAIL PROTECTED]:
Martin Alterisio wrote:
Double slash to prevent PHP interpreting the slashes. Also using single
quotes would be a good idea:
if (preg_match('/[\\w\\x2F]{6,}/',$a))
Just switching to single quotes would do the trick - you don't need to
escape
Double slash to prevent PHP interpreting the slashes. Also using single
quotes would be a good idea:
if (preg_match('/[\\w\\x2F]{6,}/',$a))
2007/1/19, Németh Zoltán [EMAIL PROTECTED]:
Hi all,
I have a simple checking like
if (preg_match(/[\w\x2F]{6,}/,$a))
as I would like to allow all
Martin Alterisio wrote:
Double slash to prevent PHP interpreting the slashes. Also using single
quotes would be a good idea:
if (preg_match('/[\\w\\x2F]{6,}/',$a))
Just switching to single quotes would do the trick - you don't need to
escape anything but single quotes, and backslashes if
# [EMAIL PROTECTED] / 2007-01-19 15:25:38 +0100:
Hi all,
I have a simple checking like
if (preg_match(/[\w\x2F]{6,}/,$a))
as I would like to allow all word characters as mentioned at
http://hu2.php.net/manual/hu/reference.pcre.pattern.syntax.php
plus the '/' character, and at least 6
On p, 2007-01-19 at 15:39 +, Roman Neuhauser wrote:
# [EMAIL PROTECTED] / 2007-01-19 15:25:38 +0100:
Hi all,
I have a simple checking like
if (preg_match(/[\w\x2F]{6,}/,$a))
as I would like to allow all word characters as mentioned at
Not a big regex expert, but first off i would recommend not using / as a
delimiter for your pattern if you are trying to catch forward slashes in
your text.
I would use a pattern like:
#[a-zA-Z0-9/]{6,}#
Regards,
Tim
-Message d'origine-
De : Németh Zoltán [mailto:[EMAIL PROTECTED]
On Mon, August 21, 2006 2:13 pm, Dave Goodchild wrote:
On 21/08/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
hi.
I have to check if the script file belongs to any ov form1.php to
form6.php files. Need something like:
preg_match('/form*.php/', $_SERVER['PHP_SELF'])
wher * kan be any
On 21/08/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
hi.
I have to check if the script file belongs to any ov form1.php to
form6.php files. Need something like:
preg_match('/form*.php/', $_SERVER['PHP_SELF'])
wher * kan be any number between 1 and 6.
Thanks for any help.
the pattern is
I think this pattern would also match form16.php etc, which I think is
not what afan wanted.
Dave Goodchild wrote:
On 21/08/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
hi.
I have to check if the script file belongs to any ov form1.php to
form6.php files. Need something like:
Works perfect. Thanks!
;)
-afan
function doMatch($f) {
echo $f,
= ,
(preg_match(#^form[1-6]\.php\$#,basename($f))?true:false),
\n;
}
doMatch(form1.php); // true
doMatch(form2.php); // true
doMatch(form3.php); // true
doMatch(form4.php);
function doMatch($f) {
echo $f,
= ,
(preg_match(#^form[1-6]\.php\$#,basename($f))?true:false),
\n;
}
doMatch(form1.php); // true
doMatch(form2.php); // true
doMatch(form3.php); // true
doMatch(form4.php); // true
doMatch(form5.php); //
I am getting an error on the following line:
if(preg_match('s/l$//', $string))
The error is:
Warning: Delimiter must not be alphanumeric or backslash in
/u1/jab/devel/whitespace/whitespace.php on line 136.
I know that pcre in PHP is not exactly interchangeable. Any ideas on
how
to
30 matches
Mail list logo