Re: [PHP] preg_match fails to resolve variable as a subject

2010-12-03 Thread Richard Quadling
On 3 December 2010 11:13, Da Rock wrote: > On 12/03/10 16:33, Tamara Temple wrote: >> >> On Dec 2, 2010, at 11:33 PM, Da Rock wrote: >> >>> On 11/29/10 09:10, Richard Quadling wrote: On 27 November 2010 04:45, Da Rock  wrote: > On 11/27/10 13:51, Tamara Temple wrote: >

Re: [PHP] preg_match fails to resolve variable as a subject

2010-12-03 Thread Richard Quadling
On 3 December 2010 11:13, Da Rock wrote: > On 12/03/10 16:33, Tamara Temple wrote: >> >> On Dec 2, 2010, at 11:33 PM, Da Rock wrote: >> >>> On 11/29/10 09:10, Richard Quadling wrote: On 27 November 2010 04:45, Da Rock  wrote: > On 11/27/10 13:51, Tamara Temple wrote: >

Re: [PHP] preg_match fails to resolve variable as a subject

2010-12-03 Thread Da Rock
On 12/03/10 16:33, Tamara Temple wrote: On Dec 2, 2010, at 11:33 PM, Da Rock wrote: On 11/29/10 09:10, Richard Quadling wrote: On 27 November 2010 04:45, Da Rock wrote: On 11/27/10 13:51, Tamara Temple wrote: On Nov 26, 2010, at 7:28 PM, Da Rock wrote: On 11/27/10 00:57, Richard Quad

Re: [PHP] preg_match fails to resolve variable as a subject

2010-12-02 Thread Tamara Temple
On Dec 2, 2010, at 11:33 PM, Da Rock wrote: On 11/29/10 09:10, Richard Quadling wrote: On 27 November 2010 04:45, Da Rockl...@herveybayaustralia.com.au> wrote: On 11/27/10 13:51, Tamara Temple wrote: On Nov 26, 2010, at 7:28 PM, Da Rock wrote: On 11/27/10 00:57, Richard Quadling wrote:

Re: [PHP] preg_match fails to resolve variable as a subject

2010-12-02 Thread Da Rock
On 11/29/10 09:10, Richard Quadling wrote: On 27 November 2010 04:45, Da Rock wrote: On 11/27/10 13:51, Tamara Temple wrote: On Nov 26, 2010, at 7:28 PM, Da Rock wrote: On 11/27/10 00:57, Richard Quadling wrote: On 26 November 2010 00:07, Da Rock wrote:

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-28 Thread Richard Quadling
On 27 November 2010 04:45, Da Rock wrote: > On 11/27/10 13:51, Tamara Temple wrote: >> >> On Nov 26, 2010, at 7:28 PM, Da Rock wrote: >> >>> On 11/27/10 00:57, Richard Quadling wrote: On 26 November 2010 00:07, Da Rock  wrote: > preg_match("/(\d{1,3})(\.)$/", exec($mixer .

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-26 Thread Da Rock
On 11/27/10 13:51, Tamara Temple wrote: On Nov 26, 2010, at 7:28 PM, Da Rock wrote: On 11/27/10 00:57, Richard Quadling wrote: On 26 November 2010 00:07, Da Rock wrote: preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),&$matches) Can you ... var_dump(exec($mixer . ' ' . $co

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-26 Thread Tamara Temple
On Nov 26, 2010, at 7:28 PM, Da Rock wrote: On 11/27/10 00:57, Richard Quadling wrote: On 26 November 2010 00:07, Da Rockl...@herveybayaustralia.com.au> wrote: preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),& $matches) Can you ... var_dump(exec($mixer . ' ' . $command));

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-26 Thread Da Rock
On 11/27/10 00:57, Richard Quadling wrote: On 26 November 2010 00:07, Da Rock wrote: preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command),&$matches) Can you ... var_dump(exec($mixer . ' ' . $command)); I wonder if the output includes a new line which you are not accounting

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-26 Thread Tamara Temple
On Nov 25, 2010, at 6:07 PM, Da Rock wrote: preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command), & $matches) it looks like you're failing to account for the newline that comes back in a command execution. Add trim() around the exec() call and try again. -- PHP General Mailing Li

Re: [PHP] preg_match fails to resolve variable as a subject

2010-11-26 Thread Richard Quadling
On 26 November 2010 00:07, Da Rock wrote: > preg_match("/(\d{1,3})(\.)$/", exec($mixer . ' ' . $command), &$matches) Can you ... var_dump(exec($mixer . ' ' . $command)); I wonder if the output includes a new line which you are not accounting for in the regex. -- Richard Quadling Twitter : EE

Re: [PHP] preg_match? Or something else?

2010-04-02 Thread Nathan Rixham
Jim Lucas wrote: > Ashley M. Kirchner wrote: >> I have an array that's created as follows: >> >> >> >> $string = "73G146C 311- 309.1C"; >> >> >> Anyone want to take a stab at it? >> >> > > Conditionals are your friend! > > > $string = "73G146C 311- 309.1C"; > > $arr = pre

Re: [PHP] preg_match? Or something else?

2010-04-02 Thread Jim Lucas
Ashley M. Kirchner wrote: > I have an array that's created as follows: > > > > $string = "73G146C 311- 309.1C"; > > $arr = preg_split("/[\s]+/", $string); > > > > Now I need to take each element in that array, and break them up even > further so that I get: > > > > 73G=>

RE: [PHP] preg_match()

2009-09-09 Thread Jan Reiter
Thanks! Thats about what I'm doing right now. function parse_prim_states($in) { preg_match('@prim_states[\s]*\((?[0-9\s]*)@' ,$in , $matches); $this->num_prim_states = (int)$matches['number']; preg_match_all('@prim_state[\s]*\((?[a-fA-F0-

RE: [PHP] preg_match()

2009-09-09 Thread Jan Reiter
trying to avoid. But maybe that's what I have to after all if there is no other way. Thanks & Regards, Jan -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Wednesday, September 09, 2009 6:21 PM To: Jan Reiter Cc: php-general@lists.php.net Subject: R

Re: [PHP] preg_match()

2009-09-09 Thread Ashley Sheridan
On Wed, 2009-09-09 at 18:18 +0200, Jan Reiter wrote: > Good Afternoon. > > > > This shouldn't be too complicated, but I can't come up with a solution for > the problem right now. It's about RegEx in PHP (5.2) > > > > Is there a way to capture ALL sub elements of an expression like > preg_ma

RE: [PHP] preg_match too greedy

2009-07-31 Thread Ford, Mike
> -Original Message- > From: b [mailto:p...@logi.ca] > Sent: 30 July 2009 03:17 > > > > > >>> echo (preg_match($pattern, $test) != false) > > > > The " != false " here is redundant. > > Understood. But what you think is redundancy is, to me, clarity in > programming. I happen to think th

Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
Ben Dunlap wrote: > have -- "($x != false)" -- will be true whether $x is 0, NULL, an empty > string, [8<] > But "$x !== false" will only be true in the last case. Sorry, replace "be true" with "be false" above. -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http

Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
echo (preg_match($pattern, $test) != false) >> >> The " != false " here is redundant. > > Understood. But what you think is redundancy is, to me, clarity in > programming. I happen to think that boolean tests shouldn't ride on > whether or not an array returned from a function is empty or not

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 11:18 PM, Daniel Kolbo wrote: b wrote: On 07/29/2009 07:48 PM, Daniel Kolbo wrote: code works (no match) for me too on php 5.2.6 build date May 2 2008 18:01:20 with dumbdows NT. preg_match fails but for a reason other than what I think you may be expecting. It fails b/c of the f

Re: [PHP] preg_match too greedy

2009-07-29 Thread Daniel Kolbo
b wrote: > On 07/29/2009 07:48 PM, Daniel Kolbo wrote: >> >> code works (no match) for me too on php 5.2.6 build date May 2 2008 >> 18:01:20 with dumbdows NT. >> >> preg_match fails but for a reason other than what I think you may be >> expecting. It fails b/c of the first forwards slash in $url.

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 07:48 PM, Daniel Kolbo wrote: code works (no match) for me too on php 5.2.6 build date May 2 2008 18:01:20 with dumbdows NT. preg_match fails but for a reason other than what I think you may be expecting. It fails b/c of the first forwards slash in $url. The regex engine doesn't

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 03:03 PM, Ben Dunlap wrote: Jim Lucas wrote: I expected 'no match' but get 'match'. [8<] cut/paste your code and it works for me. Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What version do you have? 5.2.9 If I might suggest a couple of simplifi

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 02:07 PM, Jim Lucas wrote: b wrote: I'm trying to figure out how to test if a string matches *exactly* another string, using a regexp pattern. The manual says that ereg() is deprecated (in favour of what?) and preg_match() is giving me trouble. The problem is that I'm passing the e

Re: [PHP] preg_match too greedy

2009-07-29 Thread Daniel Kolbo
Jim Lucas wrote: > Ben Dunlap wrote: >> Jim Lucas wrote: I expected 'no match' but get 'match'. >> [8<] >>> cut/paste your code and it works for me. >> Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What >> version do you have? > > PHP 5.2.5 with Suhosin-Patch 0.9.6.

Re: [PHP] preg_match too greedy

2009-07-29 Thread Jim Lucas
Ben Dunlap wrote: > Jim Lucas wrote: >>> I expected 'no match' but get 'match'. > [8<] >> cut/paste your code and it works for me. > > Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What > version do you have? PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Mar 11 200

Re: [PHP] preg_match too greedy

2009-07-29 Thread Ben Dunlap
Jim Lucas wrote: >> I expected 'no match' but get 'match'. [8<] > cut/paste your code and it works for me. Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What version do you have? If I might suggest a couple of simplifications that would make it easier to follow/troubles

Re: [PHP] preg_match too greedy

2009-07-29 Thread Jim Lucas
b wrote: > I'm trying to figure out how to test if a string matches *exactly* > another string, using a regexp pattern. The manual says that ereg() is > deprecated (in favour of what?) and preg_match() is giving me trouble. > The problem is that I'm passing the end-of-line delimiter ($) but it > se

Re: [PHP] preg_match and multibyte

2009-04-09 Thread Merlin Morgenstern
tedd wrote: At 4:18 PM +0200 4/9/09, Merlin Morgenstern wrote: Hello, I am trying to extract a number out of a string that is in utf-8 and contains chines characters. This unfortunatelly does not work: preg_match('{(\d+)}', $details, $m); $number = $m[1]; I also tried to

Re: [PHP] preg_match and multibyte

2009-04-09 Thread tedd
At 4:18 PM +0200 4/9/09, Merlin Morgenstern wrote: Hello, I am trying to extract a number out of a string that is in utf-8 and contains chines characters. This unfortunatelly does not work: preg_match('{(\d+)}', $details, $m); $number = $m[1]; I also tried to

Re: [PHP] preg_match and dates

2009-03-02 Thread Michael A. Peters
Per Jessen wrote: Michael A. Peters wrote: What I'm trying to do is write a preg matches for each case I come across - if it matches the preg, it then parses according to the pattern to get me an acceptable -MM-DD (not sure how I'll deal with the season case yet ... but I'm serious, that ki

Re: [PHP] preg_match and dates

2009-03-02 Thread Per Jessen
Michael A. Peters wrote: This is what I have so far - $pattern[] = "/^([0-9]{1,2})[\s-]([A-Z][a-z]*)[\s-]([0-9]{4,4})$/i"; $clean[] = "\\3-\\2-\\1"; $pattern[] = "/^([A-Z][a-z]*)[\s-]([0-9]{4,4})$/"; $clean[] = "\\2-\\1-01"; $foo = preg_replace($pattern, $clean, $verb_date); If I were yo

Re: [PHP] preg_match and dates

2009-03-02 Thread Per Jessen
Michael A. Peters wrote: > What I'm trying to do is write a preg matches for each case I come > across - if it matches the preg, it then parses according to the > pattern to get me an acceptable -MM-DD (not sure how I'll deal > with the season case yet ... but I'm serious, that kind of thing i

Re: [PHP] preg_match question...

2009-02-06 Thread Jim Lucas
bruce wrote: > hi... > > trying to figure out the best approach to using preg_match to extract the > number from the follwing type of line... > > " 131646 sometext follows.." > > basically, i want to extract the number, without the text, but i have to be > able to match on the "text" > > i've b

Re: [PHP] preg_match question...

2009-02-06 Thread Alpár Török
preg_match('/^([0-9]+) (.)+/',$sString,$aMatches); Matches will be 1 => the number ; 2 => the text. The expression only matches if there is any character after the space. Not necessarily text, it might be another number or special characters 2009/2/6 bruce > hi... > > trying to figure out the

RE: [PHP] preg_match

2008-10-27 Thread Boyd, Todd M.
> -Original Message- > From: Alex Chamberlain [mailto:[EMAIL PROTECTED] > Sent: Monday, October 27, 2008 10:09 AM > To: PHP General list > Subject: [PHP] preg_match > > Hi, > > I don't understand regular expressions at all - I will make an effort > to > learn about them one day, but I nee

Re: [PHP] preg_match

2008-10-27 Thread Stut
Please keep the conversation on the list! On 27 Oct 2008, at 16:06, Alex Chamberlain wrote: -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: 27 October 2008 15:54 To: Alex Chamberlain Cc: 'PHP General list' Subject: Re: [PHP] preg_match On 27 Oct 2008, at 1

Re: [PHP] preg_match

2008-10-27 Thread Eric Butera
On Mon, Oct 27, 2008 at 11:54 AM, Stut <[EMAIL PROTECTED]> wrote: > On 27 Oct 2008, at 15:46, Alex Chamberlain wrote: >> >> Problem solved: >> function __autoload($c) { >> $m = array(); >> preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m); >> if (count($m)) { >> require_once(realpath(FS_CONTRO

Re: [PHP] preg_match

2008-10-27 Thread Stut
On 27 Oct 2008, at 15:46, Alex Chamberlain wrote: Problem solved: function __autoload($c) { $m = array(); preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m); if (count($m)) { require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) . '.inc.php')); } } However (perhaps a more appropria

RE: [PHP] preg_match

2008-10-27 Thread Alex Chamberlain
> -Original Message- > From: Stut [mailto:[EMAIL PROTECTED] > Sent: 27 October 2008 15:21 > To: Alex Chamberlain > Cc: PHP General list > Subject: Re: [PHP] preg_match > > On 27 Oct 2008, at 15:08, Alex Chamberlain wrote: > > I don’t understand regular expre

Re: [PHP] preg_match

2008-10-27 Thread Stut
On 27 Oct 2008, at 15:08, Alex Chamberlain wrote: I don’t understand regular expressions at all – I will make an effort to learn about them one day, but I need a solution today. I want to use the __autoload function, but not for all my class only those that finish in ‘Controller’. So for in

Re: [PHP] preg_match() returns false but no documentation why

2007-05-31 Thread Richard Lynch
On Wed, May 30, 2007 5:04 pm, Jim Lucas wrote: > btw: why is there a period in the second pattern? Also, why are you > allowing for uppercase letters > when the RFC's don't allow them? LDAP URL domain can't be ALL CAPS?! Last I heard, domain names were case-insensitive in every other URL... --

Re: [PHP] preg_match() returns false but no documentation why

2007-05-31 Thread Richard Lynch
On Wed, May 30, 2007 4:25 pm, Jared Farrish wrote: > On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> >> If you can't find them documented, print them out: >> >> echo "PREG_NO_ERROR: '", PREG_NO_ERROR, '"; >> > > Doh! > > PREG_NO_ERROR: 0 > PREG_INTERNAL_ERROR: 1 > PREG_BACKTRACK_LIMIT_ERROR

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Crayon Shin Chan
On Thursday 31 May 2007 01:33, Jared Farrish wrote: > Can anybody spot why this doesn't seem to be working right? The manual > ( http://us2.php.net/preg_match) says it returns "false" on error, but > preg_last_error() returns 0, which I assume points to the > "PREG_NO_ERROR" error code. > > > pre

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Jim Lucas
Stut wrote: Jared Farrish wrote: On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: > > preg_match("^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$this->server) You are missing the start/end delimiters is your first problem... Which ones? I

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Jared Farrish
On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: If you can't find them documented, print them out: echo "PREG_NO_ERROR: '", PREG_NO_ERROR, '"; Doh! PREG_NO_ERROR: 0 PREG_INTERNAL_ERROR: 1 PREG_BACKTRACK_LIMIT_ERROR: 2 PREG_RECURSION_LIMIT_ERROR: 3 PREG_BAD_UTF8_ERROR: 4 So apparently,

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 3:25 pm, Jared Farrish wrote: > On 5/30/07, Stut <[EMAIL PROTECTED]> wrote: >> >> You need delimiters around the regex, as stated in the >> documentation. >> >> preg_match("/^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/",$this->server) >> >> Although you don't need to use slashes

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Jared Farrish
On 5/30/07, Stut <[EMAIL PROTECTED]> wrote: You need delimiters around the regex, as stated in the documentation. preg_match("/^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/",$this->server) Although you don't need to use slashes, you can use any character you want but you must escape it in if it

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 3:06 pm, Jared Farrish wrote: > On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: >> > >> > preg_match("^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$this->server) >> >> You are missing the start/end delimiters is your

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Stut
Jared Farrish wrote: On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: > > preg_match("^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$this->server) You are missing the start/end delimiters is your first problem... Which ones? I've got the s

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Jared Farrish
On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> wrote: On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: > > preg_match("^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$this->server) You are missing the start/end delimiters is your first problem... Which ones? I've got the starter "^" and the clo

Re: [PHP] preg_match() returns false but no documentation why

2007-05-30 Thread Richard Lynch
On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: > Hi all, > > Can anybody spot why this doesn't seem to be working right? The manual > ( > http://us2.php.net/preg_match) says it returns "false" on error, but > preg_last_error() returns 0, which I assume points to the > "PREG_NO_ERROR" > error c

Re: [PHP] preg_match

2007-02-06 Thread James Lockie
Myron Turner wrote: James Lockie wrote: I am trying to use this code to display a button at the root but it always displays the button. :-( if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { # display a button You got the end-of-string character ($) in the wrong place: i

Re: [PHP] preg_match

2007-02-06 Thread Myron Turner
James Lockie wrote: I am trying to use this code to display a button at the root but it always displays the button. :-( if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { # display a button You got the end-of-string character ($) in the wrong place: if (! (preg_match( "/\

Re: [PHP] preg_match

2007-02-06 Thread Richard Lynch
On Tue, February 6, 2007 7:46 pm, James Lockie wrote: > I am trying to use this code to display a button at the root but it > always displays the button. :-( > > if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { Without any "modifier", $ matches the END of the string. It is impo

Re: [PHP] preg_match problem

2007-01-25 Thread Richard Lynch
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

Re: [PHP] preg_match problem

2007-01-25 Thread Jim Lucas
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

RE: [PHP] preg_match problem

2007-01-25 Thread Beauford
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 >

Re: [PHP] preg_match problem

2007-01-25 Thread Jim Lucas
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 str

RE: [PHP] preg_match problem

2007-01-24 Thread Paul Novitski
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'; > } > H

RE: [PHP] preg_match problem

2007-01-24 Thread Beauford
> 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.

RE: [PHP] preg_match problem

2007-01-23 Thread Beauford
> 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 rec

RE: [PHP] preg_match problem

2007-01-23 Thread Paul Novitski
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_.'

Re: [PHP] preg_match problem

2007-01-23 Thread Jim Lucas
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 t

Re: [PHP] preg_match problem

2007-01-23 Thread Jim Lucas
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 {

RE: [PHP] preg_match problem

2007-01-23 Thread Beauford
> 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 b

RE: [PHP] preg_match problem

2007-01-23 Thread Beauford
> 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 interpr

Re: [PHP] preg_match problem

2007-01-23 Thread Paul Novitski
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 fails

Re: [PHP] preg_match problem

2007-01-23 Thread Roman Neuhauser
# [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 objecti

Re: [PHP] preg_match problem

2007-01-23 Thread Martin Alterisio
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

RE: [PHP] preg_match problem

2007-01-22 Thread Paul Novitski
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() [fu

RE: [PHP] preg_match problem

2007-01-22 Thread Beauford
> -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

Re: [PHP] preg_match problem

2007-01-22 Thread Paul Novitski
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 oth

Re: [PHP] preg_match problem

2007-01-21 Thread Martin Alterisio
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 a

Re: [PHP] preg_match problem

2007-01-20 Thread Arpad Ray
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 the

Re: [PHP] preg_match problem

2007-01-20 Thread Martin Alterisio
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

RE: [PHP] preg_match problem

2007-01-19 Thread Tim
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]

Re: [PHP] preg_match problem

2007-01-19 Thread Németh Zoltán
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 > > http://hu2.php.net/

Re: [PHP] preg_match problem

2007-01-19 Thread Roman Neuhauser
# [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

Re: [PHP] Preg_match - Find URL and convert to lower case

2006-12-01 Thread Kevin Murphy
On Dec 1, 2006, at 1:56 PM, Richard Lynch wrote: On Thu, November 30, 2006 5:04 pm, Kevin Murphy wrote: Well the problem would be then that the entire string would be lower case, and I only can have the link as lower case. Is there a way to apply strtolower into the preg_match? Why not use lo

Re: [PHP] Preg_match - Find URL and convert to lower case

2006-12-01 Thread Richard Lynch
On Thu, November 30, 2006 5:04 pm, Kevin Murphy wrote: > Well the problem would be then that the entire string would be lower > case, and I only can have the link as lower case. Is there a way to > apply strtolower into the preg_match? Why not use lower(link) in SQL to get the link out in the firs

Re: [PHP] Preg_match - Find URL and convert to lower case

2006-11-30 Thread Kevin Murphy
Well the problem would be then that the entire string would be lower case, and I only can have the link as lower case. Is there a way to apply strtolower into the preg_match? -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3

Re: [PHP] Preg_match - Find URL and convert to lower case

2006-11-30 Thread Dave Goodchild
Why not use strtolower on the string after the replacements have been made? -- http://www.web-buddha.co.uk

Re: [PHP] preg_match problem

2006-08-22 Thread Richard Lynch
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']) >> whe

Re: [PHP] preg_match problem

2006-08-21 Thread Jochem Maas
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("fo

Re: [PHP] preg_match problem

2006-08-21 Thread afan
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"); // t

Re: [PHP] preg_match problem

2006-08-21 Thread Alex Turner
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: preg_match(

Re: [PHP] preg_match problem

2006-08-21 Thread Dave Goodchild
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 f

Re: [PHP] preg_match

2006-08-10 Thread Dave Goodchild
On 10/08/06, Peter Lauri <[EMAIL PROTECTED]> wrote: Hi there, You are correct that I am stupid to call the manual bad, it was not meant like that. It was that it was not suited to me, and that I actually just wanted to find a solution to my problem directly, and it did not give me that. I have

RE: [PHP] preg_match

2006-08-10 Thread Peter Lauri
--Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 09, 2006 6:06 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] preg_match Peter Lauri wrote: > Hi, > > > > How do I add so that it checks for a comma , in thi

Re: [PHP] preg_match

2006-08-09 Thread Jochem Maas
Peter Lauri wrote: > Hi, > > > > How do I add so that it checks for a comma , in this preg_match. I think the > documentation is not that good for the pref_match: it's a lot better than you spelling of preg_match. the subject of regexps is very complex, the documentation reflects that - but t

Re: [PHP] preg_match

2006-08-09 Thread Dave Goodchild
On 09/08/06, Peter Lauri <[EMAIL PROTECTED]> wrote: Hi, How do I add so that it checks for a comma , in this preg_match. I think the documentation is not that good for the pref_match: preg_match('/^[a-z0-9-_\'() +]*$/i', $s); Check for a comma inside a range - use a comma! -- h

Re: [PHP] Preg_match() regex

2006-04-22 Thread Kevin Waterson
This one time, at band camp, "Jeff" <[EMAIL PROTECTED]> wrote: > Hey all, > > Regex pattern question here. I need to match on "Foo-F00", "Foo-foo", > "foo-Foo". I know in perl you can use the /i to specify "case > insensitive" matching. Is there any such switch that can be used in > preg_match

Re: [PHP] Preg_match() regex

2006-04-21 Thread Richard Lynch
On Fri, April 21, 2006 10:44 am, Jeff wrote: > Regex pattern question here. I need to match on "Foo-F00", "Foo-foo", > "foo-Foo". I know in perl you can use the /i to specify "case > insensitive" matching. Is there any such switch that can be used in > preg_match() in PHP? If you go to the http

Re: [PHP] Preg_match() regex

2006-04-21 Thread Joe Henry
On Friday 21 April 2006 9:44 am, Jeff wrote: > Regex pattern question here. I need to match on "Foo-F00", "Foo-foo", > "foo-Foo". I know in perl you can use the /i to specify "case > insensitive" matching. Is there any such switch that can be used in > preg_match() in PHP? http://us3.php.net/m

Re: [PHP] preg_match

2006-03-31 Thread chris smith
On 4/1/06, Benjamin D Adams <[EMAIL PROTECTED]> wrote: > I'm trying to check a string for ../ > if(preg_match("/..//i", $string)){ > echo "string has ../"; > } > ?> > > Can't get it to work can anyone help? Since / is your delimiter you need to escape it. Also '.'

Re: [PHP] preg_match

2006-03-31 Thread Jasper Bryant-Greene
Benjamin D Adams wrote: I'm trying to check a string for ../ Can't get it to work can anyone help? That's terrible overkill. Regex is not designed for simple substring matching. You want: if( strpos( $string, '../' ) !== false ) echo 'string has ../'; By the way, your problem is t

Re: [PHP] preg_match help please

2005-09-08 Thread Steve Turnbull
On Thu, 08 Sep 2005 16:36:36 +0100, Steve Turnbull wrote: > On Thu, 08 Sep 2005 09:15:03 +0100, Steve Turnbull wrote: > >> On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote: >> >>> Steve Turnbull wrote: I am trying to find a regular expression to match a variable, what I think

Re: [PHP] preg_match help please

2005-09-08 Thread Steve Turnbull
On Thu, 08 Sep 2005 09:15:03 +0100, Steve Turnbull wrote: > On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote: > >> Steve Turnbull wrote: >>> I am trying to find a regular expression to match a variable, what I think >>> should work (but doesn't) is; >>> >>> preg_match ('^/[\w],[\w]

RE: [PHP] preg_match help please

2005-09-08 Thread Ford, Mike
On 08 September 2005 09:15, Steve Turnbull wrote: > On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote: > > > Steve Turnbull wrote: > > > I am trying to find a regular expression to match a variable, > > > what I think should work (but doesn't) is; > > > > > > preg_match ('^/[\w],[\

  1   2   3   >