Re: [PHP] ereg() problem
jekillen wrote: Hello php list; I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); do we need to break out of the text to include the $to variable?? testing $route I get: do you mean $get_route? $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) Is this an example of th input? What does an actual line of $get_route look like? do a var_dump($m); and show output jk is all I am looking for but is it greed that is missing the forward slash and the single quote? It seems like every time I do this I have to monkey around with it until I get what I want. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I am using php v5.1.2 with Apache 1.3.34 Thanks in advance. JK or better yet, try this I am assuming on the actual structure of $get_route but the following return to me $match[1] = '../jk' $to = 'something'; $get_route = route name='something' x='../jk/in' rec='998asdf' /; preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, $get_route, $matches); var_dump($matches); -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem
On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote: jekillen wrote: Hello php list; I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); do we need to break out of the text to include the $to variable?? The $to variable is what I use to id the tag to get the path from, it is critical. It is like answering the question 'What is Joe's address?' Joe in this example is the $to variable. testing $route I get: do you mean $get_route? No, I mean $route after I have assigned $m[1] to it; $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) Is this an example of th input? This is what the regular expression (.*) is matching in the tag. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. What does an actual line of $get_route look like? $get_route is what was read from the XML file. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. do a var_dump($m); and show output The problem is that the regex is missing the closing single quote and matching to the end of the tag instead of just matching what is between the parenthesis. jk is all I am looking for but is it greed that is missing the forward slash and the single quote? It seems like every time I do this I have to monkey around with it until I get what I want. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I am using php v5.1.2 with Apache 1.3.34 Thanks in advance. JK or better yet, try this I am assuming on the actual structure of $get_route but the following return to me $match[1] = '../jk' $to = 'something'; $get_route = route name='something' x='../jk/in' rec='998asdf' /; preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, $get_route, $matches); var_dump($matches); O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is supposed to contain the matches made by each set of parenthesis. Does anyone know or understand the concept of greed in regular expressions, and how to turn it off in php? That is all I am asking for. JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem
On Tue, January 30, 2007 8:36 pm, jekillen wrote: I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); testing $route I get: $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) jk is all I am looking for but is it greed that is missing the forward slash and the single quote? No, it's that you put the parens () around only the .* and not around what you wanted: ereg(route name='$to' x='\\.\\.(.*/in') rec='.*' /, ... It seems like every time I do this I have to monkey around with it until I get what I want. Join the club. :-) You may want to consider a couple actions: Switch to PCRE http://php.net/pcre It's better documented, less confusing, faster, and just better all around. Download and play around with The Regex Coach which provides a visual feedback on what happens when you change the #$^% inside your pattern. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I haven't used ereg in so long, I can't answer this for ereg. In PCRE, you use tack on 'U' after your end patter delimiter. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem
jekillen wrote: On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote: jekillen wrote: Hello php list; I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); do we need to break out of the text to include the $to variable?? The $to variable is what I use to id the tag to get the path from, it is critical. It is like answering the question 'What is Joe's address?' Joe in this example is the $to variable. testing $route I get: do you mean $get_route? No, I mean $route after I have assigned $m[1] to it; $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) Is this an example of th input? This is what the regular expression (.*) is matching in the tag. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. What does an actual line of $get_route look like? $get_route is what was read from the XML file. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. do a var_dump($m); and show output The problem is that the regex is missing the closing single quote and matching to the end of the tag instead of just matching what is between the parenthesis. jk is all I am looking for but is it greed that is missing the forward slash and the single quote? It seems like every time I do this I have to monkey around with it until I get what I want. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I am using php v5.1.2 with Apache 1.3.34 Thanks in advance. JK or better yet, try this I am assuming on the actual structure of $get_route but the following return to me $match[1] = '../jk' $to = 'something'; $get_route = route name='something' x='../jk/in' rec='998asdf' /; preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, $get_route, $matches); var_dump($matches); O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is supposed to contain the matches made by each set of parenthesis. Does anyone know or understand the concept of greed in regular expressions, and how to turn it off in php? That is all I am asking for. JK Check out this working example of what I think you are asking for. http://www.cmsws.com/examples/php/ereg.phps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem
jekillen wrote: On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote: jekillen wrote: Hello php list; I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); do we need to break out of the text to include the $to variable?? The $to variable is what I use to id the tag to get the path from, it is critical. It is like answering the question 'What is Joe's address?' Joe in this example is the $to variable. testing $route I get: do you mean $get_route? No, I mean $route after I have assigned $m[1] to it; $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) Is this an example of th input? This is what the regular expression (.*) is matching in the tag. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. What does an actual line of $get_route look like? $get_route is what was read from the XML file. It will have a steadily increasing number of tags in the above pattern and nothing else (accept for opening and closing xml tags. do a var_dump($m); and show output The problem is that the regex is missing the closing single quote and matching to the end of the tag instead of just matching what is between the parenthesis. jk is all I am looking for but is it greed that is missing the forward slash and the single quote? It seems like every time I do this I have to monkey around with it until I get what I want. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I am using php v5.1.2 with Apache 1.3.34 Thanks in advance. JK or better yet, try this I am assuming on the actual structure of $get_route but the following return to me $match[1] = '../jk' $to = 'something'; $get_route = route name='something' x='../jk/in' rec='998asdf' /; preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, $get_route, $matches); var_dump($matches); O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is supposed to contain the matches made by each set of parenthesis. Does anyone know or understand the concept of greed in regular expressions, and how to turn it off in php? That is all I am asking for. JK Sent you the source link. Try it without the 's' at the end. http://www.cmsws.com/examples/php/ereg.php http://www.cmsws.com/examples/php/ereg.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem: solution
Hi In reference to my query about 'greed' in regex in php and the following code $x = ereg(route name='$to' x='\.\./(.*)/in' rec='.*' /, $get_route, $m); I solved the immediate problem with the following: route name='$to' x='\.\./([a-z]{2}|a?u_[0-9a-z]{8})/in' rec='.*' / as you can see, the regex is quite a bit more complicated and I do not know if it will match all the possibilities that it will have to. It looks like it should. one possibility that it is matching is just two letters, in this case jk. The other possibility is u_ or au_ followed by 8 randomly selected letters and/or numbers. In short I was trying to be as simple and comprehensive as possible with (.*) as the regular expression. But the idea of greed came to mind when the match was containing far more than antic- ipated. Greed is when the regular expression tries to match as much as possible, in this case (.*) appears to be matching every instance of anything and everything else in the way, so it ends up including the entire balance of the line. A least that is my explanation. So I did something more complicated to get what I wanted. Simplicity is not always so simple. Thanks for all responses. JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg() problem
On Jan 31, 2007, at 4:38 PM, Richard Lynch wrote: On Tue, January 30, 2007 8:36 pm, jekillen wrote: I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); testing $route I get: $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) jk is all I am looking for but is it greed that is missing the forward slash and the single quote? No, it's that you put the parens () around only the .* and not around what you wanted: ereg(route name='$to' x='\\.\\.(.*/in') rec='.*' /, ... It seems like every time I do this I have to monkey around with it until I get what I want. Join the club. :-) You may want to consider a couple actions: Switch to PCRE http://php.net/pcre It's better documented, less confusing, faster, and just better all around. Download and play around with The Regex Coach which provides a visual feedback on what happens when you change the #$^% inside your pattern. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I haven't used ereg in so long, I can't answer this for ereg. In PCRE, you use tack on 'U' after your end patter delimiter. Thanks, I believe I do have pcre in my installation, and that was my next target for investigation. As I turns out I got a regex that works, albeit more complicated than (.*). See this post subject + solution. by me. thanks for the response. JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg() problem
Hello php list; I am having trouble with ereg(). The following is the problem code $x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, $m); testing $route I get: $route = $m[1]; print $route.'br'; jk/in' rec='a_378e6dc4.xml' / (out put of print) jk is all I am looking for but is it greed that is missing the forward slash and the single quote? It seems like every time I do this I have to monkey around with it until I get what I want. I have even changed the formatting of files just so a regular expression would work without this sort of trial and error. Is there a way I can turn off greed in php's regex? I am using php v5.1.2 with Apache 1.3.34 Thanks in advance. JK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg problem
One more in my recent woes. The last elseif does not work in the code below - even if the string is correct it always says it's incorrect. Even if I remove everything else and just have the ereg satement is doesn't work either. The code below is in a function and $_POST['password1'] is passed to the function. $field = password1; //Use field name for password if(!$subpass){ $form-setError($field, Password not entered); } elseif(strlen($subpass) 6) { $form-setError($field, Too Short); } elseif(strlen($subpass) 10) { $form-setError($field, Too Long); } elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) { $form-setError($field, Not alphanumeric); } Thanks B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg problem
On Tue, 2006-06-27 at 12:14, Beauford wrote: One more in my recent woes. The last elseif does not work in the code below - even if the string is correct it always says it's incorrect. Even if I remove everything else and just have the ereg satement is doesn't work either. The code below is in a function and $_POST['password1'] is passed to the function. $field = password1; //Use field name for password if(!$subpass){ $form-setError($field, Password not entered); } elseif(strlen($subpass) 6) { $form-setError($field, Too Short); } elseif(strlen($subpass) 10) { $form-setError($field, Too Long); } elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) { $form-setError($field, Not alphanumeric); } You're double negating. You check the negative return of ereg() and ereg checks for the pattern NOT existing. ?php elseif( !ereg( '[A-Za-z0-9]', trim( $subpass ) ) ) // the ereg check is still wrong though and should be... elseif( !ereg( '^[A-Za-z0-9]+$', trim( $subpass ) ) ) // though personally, I'd use the following... elseif( !ereg( '^[[:alnum:]]+$', trim( $subpass ) ) ) ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg problem
Beauford wrote: Please turn of your mail client's request for return receipts when sending to a mailing list. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ereg problem
-Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: June 27, 2006 12:58 PM To: Beauford Cc: PHP-General Subject: Re: [PHP] Ereg problem On Tue, 2006-06-27 at 12:14, Beauford wrote: One more in my recent woes. The last elseif does not work in the code below - even if the string is correct it always says it's incorrect. Even if I remove everything else and just have the ereg satement is doesn't work either. The code below is in a function and $_POST['password1'] is passed to the function. $field = password1; //Use field name for password if(!$subpass){ $form-setError($field, Password not entered); } elseif(strlen($subpass) 6) { $form-setError($field, Too Short); } elseif(strlen($subpass) 10) { $form-setError($field, Too Long); } elseif(!ereg('[^A-Za-z0-9]', trim($subpass))) { $form-setError($field, Not alphanumeric); } You're double negating. You check the negative return of ereg() and ereg checks for the pattern NOT existing. ?php elseif( !ereg( '[A-Za-z0-9]', trim( $subpass ) ) ) // the ereg check is still wrong though and should be... elseif( !ereg( '^[A-Za-z0-9]+$', trim( $subpass ) ) ) // though personally, I'd use the following... elseif( !ereg( '^[[:alnum:]]+$', trim( $subpass ) ) ) ? Ahhh, I was thinking of it the other way round. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg problem
Don't worry about this I worked out that the example was wrong (o; - Original Message - From: Newman Weekly. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, March 13, 2004 1:59 PM Subject: [PHP] ereg problem ?php $formUserName=foobar; if (ereg(^[a-bA-B][a-bA-B0-9]{3,11}$,$formUserName) { // IS VALID. $pageUserNameValid=YES; } else { // NOT VALID $pageUserNameValid=NO; } // PAGE OUT PUT.. echo $pageUserNameValid; ? This simple script is ment to check to a user nae field but I have done something wrong. $pageUserNameValid This should be yes for foo bar. // Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg problem?
by the way, it's to complicated. the brackets [ and ] are used for cha-groups. you can leave them for only one char. so this would be the same: \\n (you have to escape the backslash with a backslash) Curt Zirzow wrote: * Thus wrote John W. Holmes ([EMAIL PROTECTED]): [EMAIL PROTECTED] wrote: who can tell me what's the pattern string mean. if(ereg([\\][n],$username)) { /*Do err*/ } It's looking for a \ character or a \ character followed by the letter n anywhere within the string $username. I hope that isn't looking for a Carriage Return, cause it never will... Just in case it is strstr($username, \n); Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ereg problem?
-Original Message- From: sven [mailto:[EMAIL PROTECTED] Sent: 25 July 2003 10:35 by the way, it's to complicated. the brackets [ and ] are used for cha-groups. you can leave them for only one char. so this would be the same: \\n (you have to escape the backslash with a backslash) And then we get into the typical double-quoted-regexp-backslash-proliferation problem -- the above will pass \n as the regexp, which matches a newline *not* the intended literal \n. So now you have to escape the escaped escape, to get: n Which passes \\n as the regexp, which does indeed match a literal \n ! Another way to go is to use single quotes around the regexp, since a single-quoted string does not interpret \-expressions (except for \', of course!) -- so this is the same regexp as above: '\\n' I know which I prefer, but YMMV of course! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg problem?
who can tell me what's the pattern string mean. if(ereg([\\][n],$username)) { /*Do err*/ } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg problem?
[EMAIL PROTECTED] wrote: who can tell me what's the pattern string mean. if(ereg([\\][n],$username)) { /*Do err*/ } It's looking for a \ character or a \ character followed by the letter n anywhere within the string $username. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg problem?
* Thus wrote John W. Holmes ([EMAIL PROTECTED]): [EMAIL PROTECTED] wrote: who can tell me what's the pattern string mean. if(ereg([\\][n],$username)) { /*Do err*/ } It's looking for a \ character or a \ character followed by the letter n anywhere within the string $username. I hope that isn't looking for a Carriage Return, cause it never will... Just in case it is strstr($username, \n); Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg problem
In article [EMAIL PROTECTED], "Janet Valade" [EMAIL PROTECTED] wrote: if you include a hyphen in a character class, it must be the last entry in the range, otherwise it is interepreted as the range separator. [0-9+.\()-] is what you want (probably have to escape some of the chars above). Jeff I am using the following statement to check phone numbers. if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Janet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] ereg problem
- hyphen is something a bit special in RegEx .. read the manual, I think you should escape it. Cheers, Maxim Maletsky -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 15, 2001 3:21 AM To: '[EMAIL PROTECTED]' Subject: [PHP] ereg problem I am using the following statement to check phone numbers. if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Janet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] ereg problem
I am using the following statement to check phone numbers. if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Janet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ereg problem
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Janet Valade) wrote: if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Try: if (!ereg("^[0-9+. )(-]{10,}$",$value)) -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ereg problem
the - needs to be immediately after the [ to include that character. Otherwise it is a range indicator. Charlie - Original Message - From: "CC Zona" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 14, 2001 12:56 PM Subject: Re: [PHP] ereg problem In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Janet Valade) wrote: if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Try: if (!ereg("^[0-9+. )(-]{10,}$",$value)) -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ereg problem
[rearranging back to bottom-posting order, for clarity] In article 006d01c096b8$4b9cf3e0$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Charlie Llewellin") wrote: - Original Message - From: "CC Zona" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 14, 2001 12:56 PM Subject: Re: [PHP] ereg problem In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Janet Valade) wrote: if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Try: if (!ereg("^[0-9+. )(-]{10,}$",$value)) the - needs to be immediately after the [ to include that character. Otherwise it is a range indicator. Not quite. The ereg_* functions are based on POSIX 1003.2, which states: "A bracket expression is a list of characters enclosed in `[]'. snip If two characters in the list are separated by ` -', this is shorthand for the full range of characters between those two (inclusive) in the collating sequence... snip To include a literal `-', make it the first __or last character__, _or the second end-point of a range_. snip" (emphasis added) -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] ereg problem
Thank you. That was exactly the problem. Janet -Original Message- From: Charlie Llewellin [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, February 14, 2001 11:00 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] ereg problem the - needs to be immediately after the [ to include that character. Otherwise it is a range indicator. Charlie - Original Message - From: "CC Zona" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 14, 2001 12:56 PM Subject: Re: [PHP] ereg problem In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Janet Valade) wrote: if (!ereg("^[0-9\-\+\.\ \)\(]{10,}$",$value)) { Can anyone tell me why this works for every character except the -. It doesn't see the hyphen as a valid part of the phone number, even though it recognizes the other characters, e.g. + or . Try: if (!ereg("^[0-9+. )(-]{10,}$",$value)) -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]