Re: [PHP] ereg help!
$out = basename($file, .html) . .com; fairly limited i think, but simple. Nothing wrong with being simple, and therefore both fast and easy to understand by a wider audience. The only downer I can immediately think of though is that whitespace isn't accommodated, but who really ends a file name with white space? -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support ** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg help!
steve wrote: On Tuesday 08 January 2008 20:30:29 Chris wrote: I usually use preg_* functions so here's my go: echo preg_replace('/\.php$/', '.com', $file); The '$' at the end makes sure it's a .php file and won't cause problems with files like xyz.php.txt . (otherwise I'd just use a straight str_replace). Thanks Guess i was just trying to over think it. Have not done much with files. Steve $out = basename($file, .html) . .com; fairly limited i think, but simple. -- Regards, Anup Shukla -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg help!
I have a dir of html files that link to websites, i would like to read the dir and print a list of those files as a link. Which the script i have does. I would like to take this one step further and replace the .html extension with .com so it winds up being: website.com instead of website.html I am apparently having problems getting my head around eregi enough to acomplish this. any help is greatly appreciated. ? $source_dir = ./mydir; $dir=opendir($source_dir); $files=array(); while (($file=readdir($dir)) !== false) { if ($file != . $file != .. strpos(strtolower($file),.php) === false) { array_push($files, $file); } } closedir($dir); sort($files); foreach ($files as $file) { echo A href='$file'$filebr; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg help!
steve wrote: I have a dir of html files that link to websites, i would like to read the dir and print a list of those files as a link. Which the script i have does. I would like to take this one step further and replace the .html extension with .com so it winds up being: website.com instead of website.html I am apparently having problems getting my head around eregi enough to acomplish this. any help is greatly appreciated. ? $source_dir = ./mydir; $dir=opendir($source_dir); $files=array(); while (($file=readdir($dir)) !== false) { if ($file != . $file != .. strpos(strtolower($file),.php) === false) { array_push($files, $file); } } closedir($dir); sort($files); foreach ($files as $file) { echo A href='$file'$filebr; } ? I usually use preg_* functions so here's my go: echo preg_replace('/\.php$/', '.com', $file); The '$' at the end makes sure it's a .php file and won't cause problems with files like xyz.php.txt . (otherwise I'd just use a straight str_replace). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg help!
On Tuesday 08 January 2008 20:30:29 Chris wrote: I usually use preg_* functions so here's my go: echo preg_replace('/\.php$/', '.com', $file); The '$' at the end makes sure it's a .php file and won't cause problems with files like xyz.php.txt . (otherwise I'd just use a straight str_replace). Thanks Guess i was just trying to over think it. Have not done much with files. Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg help!
On Jan 8, 2008, at 5:45 PM, steve [EMAIL PROTECTED] wrote: I have a dir of html files that link to websites, i would like to read the dir and print a list of those files as a link. Which the script i have does. I would like to take this one step further and replace the .html extension with .com so it winds up being: website.com instead of website.html I am apparently having problems getting my head around eregi enough to acomplish this. any help is greatly appreciated. ? $source_dir = ./mydir; $dir=opendir($source_dir); $files=array(); while (($file=readdir($dir)) !== false) { if ($file != . $file != .. strpos(strtolower ($file),.php) === false) { array_push($files, $file); } } closedir($dir); sort($files); foreach ($files as $file) { echo A href='$file'$filebr; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think glob('*.html'); would be easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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
[PHP] ereg function
I want to validate someones age. How do I do this in the ereg function. I also have some visitors on my site who are in between the ages of 7-9 so don't forget to make them part of the ereg function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg function
Numbers are pretty easy. You could just do: $age = (int)$_POST['age']; if($age 9) do_something(); else do_something_else(); Using ereg doesn't make much sense in this case. -Rasmus On Fri, 31 Dec 2004, Michael Lutaaya wrote: I want to validate someones age. How do I do this in the ereg function. I also have some visitors on my site who are in between the ages of 7-9 so don't forget to make them part of the ereg function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg function
The ereg function doesn't have the capability to test the age of the person viewing your page. You have to depend on them to input their age in some way. Your answer depends on how your age is submitted. Assuming it is submited as $_POST['age'], you could perhaps use ereg(0*[7-9]$, $_POST['age']) - that might work but I haven't used ereg - ever, I perfer to use the faster PCRE regex functions, such as preg_match(/^0*[7-9]$/, $_POST['age']); which will match any amount of zeros, followed by anything between 7 and 9, ie 8, 008, or 08 Having all that said, I wouldn't use reges for smething like this. On Fri, 31 Dec 2004 15:46:46 -0500 (EST), Michael Lutaaya [EMAIL PROTECTED] wrote: I want to validate someones age. How do I do this in the ereg function. I also have some visitors on my site who are in between the ages of 7-9 so don't forget to make them part of the ereg function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg question/prob...
hi... i have the following... $file = .txt; ereg((\.)([a-z0-9]{3,5})$, $file, $regs); echo ww = .$regs. brbr; i'm trying to figure out how to get the portion of the regex that's the extension of the file. my understanding of the docs, says that the extension should be in the $reg array any ideas/comments on where my mistake is would be appreciated... thanks -bruce -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg-replace ... how to catch :'( [crying smiley] ???
I'm trying to do graphical smileys for my guestbook, but I've run into a problem with the crying smilies: I need to replace :'( and :'-( ... or as they look in the post after being entered through htmlentities with ent_quotes on: :#039;( :#039;-( this causes the entire message to disappear: $text = ereg_replace(':#039;-?(','img src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 align=absmiddle',$text); only the format of the search part differs from my other smiley replacements, so obviously that's where the problem is ... afaik, neither , # or ; have any meaning in regex, so I don't get what causes it ... I've tried escaping all of those chars, and it still causes $text to come back empty... any ideas will be highly appreciated... TIA Rene -- Rene Brehmer aka Metalbunny ~ If you don't like what I have to say ... don't read it ~ http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums @ http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???
[snip] :#039;( :#039;-( this causes the entire message to disappear: $text = ereg_replace(':#039;-?(','img src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 align=absmiddle',$text); [/snip] Have you tried any of the other regular expression functions available? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}
Never mind y'all ... me stupid ... obviously the ( has meaning, and needs to be escaped ... was starting to think it could only do 2 ereg's in 1 script *sigh* Sorry for wasting time and bandwidth ... the function now looks like this and works : function gfx_smiley($text) { $smiley_path = 'smiley'; $text = eregi_replace(':-?D','img src='.$smiley_path.'/biggrin.gif alt=:D width=15 height=15 align=absmiddle',$text); $text = ereg_replace(':-?\?','img src='.$smiley_path.'/confused.gif alt=:? width=15 height=22 align=absmiddle',$text); $text = ereg_replace(':#039;-?\(','img src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 align=absmiddle',$text); $text = ereg_replace(':-?\(','img src='.$smiley_path.'/frown.gif alt=:( width=15 height=15 align=absmiddle',$text); return $text; } At 15:43 14-04-2004, -{ Rene Brehmer }- wrote: I'm trying to do graphical smileys for my guestbook, but I've run into a problem with the crying smilies: I need to replace :'( and :'-( ... or as they look in the post after being entered through htmlentities with ent_quotes on: :#039;( :#039;-( this causes the entire message to disappear: $text = ereg_replace(':#039;-?(','img src='.$smiley_path.'/crying.gif alt=:#039;( width=25 height=15 align=absmiddle',$text); only the format of the search part differs from my other smiley replacements, so obviously that's where the problem is ... afaik, neither , # or ; have any meaning in regex, so I don't get what causes it ... I've tried escaping all of those chars, and it still causes $text to come back empty... any ideas will be highly appreciated... -- Rene Brehmer aka Metalbunny ~ If you don't like what I have to say ... don't read it ~ http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums @ http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}
Hi, Thursday, April 15, 2004, 12:51:20 AM, you wrote: RB Never mind y'all ... me stupid ... RB obviously the ( has meaning, and needs to be escaped ... was starting to RB think it could only do 2 ereg's in 1 script *sigh* RB Sorry for wasting time and bandwidth ... the function now looks like this RB and works : You might find this very useful :) http://weitz.de/regex-coach/ Helps my old brain -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}
At 15:02 14-04-2004, Tom Rogers wrote: Hi, Thursday, April 15, 2004, 12:51:20 AM, you wrote: RB Never mind y'all ... me stupid ... RB obviously the ( has meaning, and needs to be escaped ... was starting to RB think it could only do 2 ereg's in 1 script *sigh* RB Sorry for wasting time and bandwidth ... the function now looks like this RB and works : You might find this very useful :) http://weitz.de/regex-coach/ Helps my old brain Hmm ... that looks like it only does Perl-based regex ??? Thing is the programs I normally do regex in either use Posix based or Unix (Cshell) based (mostly used at the latter, cuz that's what Forte Agent uses for its filters) ... how big a difference is there from the posix based to the perl based anyway ??? ... the samples in the manual ain't the same for preg_replace() and ereg_replace(), so it's a bit hard to get a quick glimpse of how big the difference really is ... (or for the _match() ones for that matter)... But thx ... looks useful :) Rene -- Rene Brehmer aka Metalbunny ~ If you don't like what I have to say ... don't read it ~ http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums @ http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}
Hi, Thursday, April 15, 2004, 8:56:05 AM, you wrote: RB At 15:02 14-04-2004, Tom Rogers wrote: Hi, Thursday, April 15, 2004, 12:51:20 AM, you wrote: RB Never mind y'all ... me stupid ... RB obviously the ( has meaning, and needs to be escaped ... was starting to RB think it could only do 2 ereg's in 1 script *sigh* RB Sorry for wasting time and bandwidth ... the function now looks like this RB and works : You might find this very useful :) http://weitz.de/regex-coach/ Helps my old brain RB Hmm ... that looks like it only does Perl-based regex ??? Thing is the RB programs I normally do regex in either use Posix based or Unix (Cshell) RB based (mostly used at the latter, cuz that's what Forte Agent uses for its RB filters) ... how big a difference is there from the posix based to the perl RB based anyway ??? ... the samples in the manual ain't the same for RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick RB glimpse of how big the difference really is ... (or for the _match() ones RB for that matter)... RB But thx ... looks useful :) RB Rene RB -- RB Rene Brehmer RB aka Metalbunny RB ~ If you don't like what I have to say ... don't read it ~ RB http://metalbunny.net/ RB References, tools, and other useful stuff... RB Check out the new Metalbunny forums @ http://forums.metalbunny.net/ Yes it is based on perl regular expressions which are pretty close to posix, close enough for simple stuff anyway. preg_replace is quite a bit faster than ereg_replace, I know preg_* functions keep a cache of expressions which can speed up repetitive uses. Not sure about ereg functions though. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Never mind ... stupid me :-/ {was Re: [PHP] ereg-replace ... how to catch :'( [crying smiley] ???}
* Thus wrote Tom Rogers ([EMAIL PROTECTED]): Hi, Thursday, April 15, 2004, 8:56:05 AM, you wrote: RB At 15:02 14-04-2004, Tom Rogers wrote: ... RB preg_replace() and ereg_replace(), so it's a bit hard to get a quick RB glimpse of how big the difference really is ... (or for the _match() ones RB for that matter)... RB But thx ... looks useful :) Yes it is based on perl regular expressions which are pretty close to posix, close enough for simple stuff anyway. preg_replace is quite a bit faster than ereg_replace, I know preg_* functions keep a cache of expressions which can speed up repetitive uses. Not sure about ereg functions though. From all benchmarks I've seen pcre beats posix hands down, not to mention that pcre is much more powerful. 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
[PHP] Ereg problems
Having some problems with ereg() [begin code] $string=Credit adjusted: $-1.32 to $48.68 ereg(([\\$(\\$-)][0-9]+\.[0-9]+),$data[2],$found); While(list($index,$hits)=each($found)) { echo $index , $hitsbr; } [end code] Returns 0 , $48.68 1 , $48.68 Am I doing something wrong with my regex or is there a problem here. What I need is all the dollar amounts pulled out (with a negative sign if there). Thanks, Jeff -- 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 + performance problem
Hi, I think that smarty [ http://smarty.php.net ] can do this for u. It has tag nesting and, of course, you can define your own tag as a plugin. As for performance problem - this is known feature of regexp. Solution is not simple. You, IMHO, have to rethink your approach. For parsing larger or complex files is much better to use state machine (finite state automaton). Try to search google for more theory. For ex. http://en.wikipedia.org/wiki/Finite_state_automaton Martin Helie wrote: Hello, I'm writing a routine that recursively reads an HTML document, looking for special tags. It's a template system, but contrary to what I've seen out there so far, no template engines allow for any kind of customization from within the document; they only seem to be variable replacement systems. What I have in mind is something along the lines of: HTML blah blah {MAGICTAG param1=a param2=b}some more {ANOTHERTAG}text{/ANOTHERTAG} here {/MAGICTAG} blah /HTML The text between ANOTHERTAG would first be changed and then passed along with the other text to MAGICTAG. ie, the data is treated from the inside out, and nesting is obviously supported. I've got everything working, but the problem is I'm using quite a few ereg statements recursively, so performance is not so good. Here's a simplified version of the core (it's part of a class, and I modified the code for a standalone version here). Thanks in advance for any ideas. Feel free to recycle this code. function parse( $template ) { //Look for (before*) {a tag} (after*) anything and store matches in $regs if( ereg( (.*)[{]([a-zA-Z0-9]+)[}](.*), $template, $regs ) ) { $before = $regs[1]; $tag = $regs[2]; //Now look for (data*) {/closing tag} (after*) in the after portion of first match if( ereg( (.*)[{][/] . $tag. [}](.*), $regs[3], $regs ) ) { $after = $regs[2]; $data = $regs[1]; $resolvedTag = initHandler( $tag, $data ); //handle this tag and data } //support for standalone tags (no {/closing tag} ) else { ereg( (.*), $regs[3], $regs ); $resolvedTag = getTagValue( $tag ); $after = $regs[1]; } } if( $resolvedTag ) { $template = $before . $resolvedTag . $after; parse( $template ); } else { return $template; } } -- Mirek Novak jabberID: [EMAIL PROTECTED] ICQ: 119499448 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg + performance problem
Hi Mirek, thanks for pointing this out. This looks like a great site -- although, as you say, will require some [longer term] study. I'll have closer look at Smarty as well... Mirek Novak [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I think that smarty [ http://smarty.php.net ] can do this for u. It has tag nesting and, of course, you can define your own tag as a plugin. As for performance problem - this is known feature of regexp. Solution is not simple. You, IMHO, have to rethink your approach. For parsing larger or complex files is much better to use state machine (finite state automaton). Try to search google for more theory. For ex. http://en.wikipedia.org/wiki/Finite_state_automaton Martin Helie wrote: Hello, I'm writing a routine that recursively reads an HTML document, looking for special tags. It's a template system, but contrary to what I've seen out there so far, no template engines allow for any kind of customization from within the document; they only seem to be variable replacement systems. What I have in mind is something along the lines of: HTML blah blah {MAGICTAG param1=a param2=b}some more {ANOTHERTAG}text{/ANOTHERTAG} here {/MAGICTAG} blah /HTML The text between ANOTHERTAG would first be changed and then passed along with the other text to MAGICTAG. ie, the data is treated from the inside out, and nesting is obviously supported. I've got everything working, but the problem is I'm using quite a few ereg statements recursively, so performance is not so good. Here's a simplified version of the core (it's part of a class, and I modified the code for a standalone version here). Thanks in advance for any ideas. Feel free to recycle this code. function parse( $template ) { //Look for (before*) {a tag} (after*) anything and store matches in $regs if( ereg( (.*)[{]([a-zA-Z0-9]+)[}](.*), $template, $regs ) ) { $before = $regs[1]; $tag = $regs[2]; //Now look for (data*) {/closing tag} (after*) in the after portion of first match if( ereg( (.*)[{][/] . $tag. [}](.*), $regs[3], $regs ) ) { $after = $regs[2]; $data = $regs[1]; $resolvedTag = initHandler( $tag, $data ); //handle this tag and data } //support for standalone tags (no {/closing tag} ) else { ereg( (.*), $regs[3], $regs ); $resolvedTag = getTagValue( $tag ); $after = $regs[1]; } } if( $resolvedTag ) { $template = $before . $resolvedTag . $after; parse( $template ); } else { return $template; } } -- Mirek Novak jabberID: [EMAIL PROTECTED] ICQ: 119499448 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg + performance problem
Hello, I'm writing a routine that recursively reads an HTML document, looking for special tags. It's a template system, but contrary to what I've seen out there so far, no template engines allow for any kind of customization from within the document; they only seem to be variable replacement systems. What I have in mind is something along the lines of: HTML blah blah {MAGICTAG param1=a param2=b}some more {ANOTHERTAG}text{/ANOTHERTAG} here {/MAGICTAG} blah /HTML The text between ANOTHERTAG would first be changed and then passed along with the other text to MAGICTAG. ie, the data is treated from the inside out, and nesting is obviously supported. I've got everything working, but the problem is I'm using quite a few ereg statements recursively, so performance is not so good. Here's a simplified version of the core (it's part of a class, and I modified the code for a standalone version here). Thanks in advance for any ideas. Feel free to recycle this code. function parse( $template ) { //Look for (before*) {a tag} (after*) anything and store matches in $regs if( ereg( (.*)[{]([a-zA-Z0-9]+)[}](.*), $template, $regs ) ) { $before = $regs[1]; $tag = $regs[2]; //Now look for (data*) {/closing tag} (after*) in the after portion of first match if( ereg( (.*)[{][/] . $tag. [}](.*), $regs[3], $regs ) ) { $after = $regs[2]; $data = $regs[1]; $resolvedTag = initHandler( $tag, $data ); //handle this tag and data } //support for standalone tags (no {/closing tag} ) else { ereg( (.*), $regs[3], $regs ); $resolvedTag = getTagValue( $tag ); $after = $regs[1]; } } if( $resolvedTag ) { $template = $before . $resolvedTag . $after; parse( $template ); } else { return $template; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg is failing on this simple test
On Fri, Dec 12, 2003 at 07:54:16PM -0800, Manuel Ochoa wrote: : : Why is this test failing? : : $data = A Simple test.; : If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) { : echo Valid text; : } : else { : echo Not valid text; : } You can't use the character class \s within a range. And you need to escape a few special characters. The working version should be: $data = 'A Simple test.'; #if (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) if (ereg(^[a-zA-Z0-9[:space:]\.\-_']+$, $data)) { echo Valid text\n; } else { echo Not valid text\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg is failing on this simple test
Why is this test failing? $data = A Simple test.; If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) { echo Valid text; } else { echo Not valid text; } I'm running PHP 4.34 on a windows pc. This function is new to me, any help would be appreciated.
RE: [PHP] ereg is failing on this simple test
Why is this test failing? If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) { I'm very new to PHP, so I may be barking up the wrong tree, but what is that s doing after the slash? I don't know if it's the cause of the problem, but as far as I know it's superfluous. -- Yoroshiku! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg
I use this expression to remove oneline comments: iereg_replace(//([^\n]*)\n,'',$code); I need to make a check if this expression is inside a string. If it is, its not a comment. I think it has something to do with context.. Anyone who could help me? thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg preg
is there any syntax difference between ereg() and preg() except preg needs / and /? -- - Eddy Wong __ inframatrix internet solutions http://www.inframatrix.com/ ¥¿¤KEddy Regular Octa-Eddy [EMAIL PROTECTED]@ [EMAIL PROTECTED]@¡½¢ª¢© [EMAIL PROTECTED]@[EMAIL PROTECTED]@¡½ É\¿ß¡G [EMAIL PROTECTED] [EMAIL PROTECTED]@¡½ É\¨¦¡G news://news.fixip.net/chat.ed [EMAIL PROTECTED]@[EMAIL PROTECTED]@¡½ É\®Þ¤Æ¡G news://news.fixip.net/ [EMAIL PROTECTED]@¡½¢¨¢« [EMAIL PROTECTED]@
Re: [PHP] ereg preg
* Thus wrote Eddy-Das ([EMAIL PROTECTED]): is there any syntax difference between ereg() and preg() except preg needs / and /? There are a lot of differences in syntax. 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
[PHP] ereg() can't recognize characters such as èéêë...
Hi list, I read through the manual and tried to find something on google, but I didn't come to anything useful. It seems that the ereg()-family (I tried ereg(), eregi() and ereg_replace()) can't recognize any special characters such as èéêë etc. I tested this : ?php print (ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri nt:][:punct:][:space:][:upper:][:xdigit:]],é)); ? and it returned a blank screen. When I fill in a regular character such as 'e' or a slash or whatever, it returns 1. I ran into this when I tested a script which should replace '{PMID[PubMed ID number]:[First author's name]} into a link to the article online. For instance, {PMID12632325:Flanigan} results in A href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM edamp;dopt=Abstractamp;list_uids=12632325 target=_blankFlanigan/A. This worked all fine, until an author's name was Müller. Then my ereg_replace() failed (below). Any ideas? ?php $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)}, A href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub Medamp;dopt=Abstractamp;list_uids=\\1\ target=\_blank\\\2/A,{PMID11519736:Müller}); print ($val); ? TIA! -- [Win2000 | Apache/1.3.23] [PHP/4.2.3 | MySQL/3.23.53] Ivo Fokkema PHP MySQL programmer Leiden University Medical Centre Netherlands -- 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
[PHP] Ereg question
I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob], $parts)) { $error[dob] = *; $message[dob] = Invalid date format!; $dob = \$parts[3]-$parts[2]-$parts[1]\; } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ereg question
I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob], $parts)) { $error[dob] = *; $message[dob] = Invalid date format!; $dob = \$parts[3]-$parts[2]-$parts[1]\; } So is $formsave['dob'] being changed before you get to this code, causing the check to fail? What else are you doing with $formsave['dob']? Nothing here is going to cause it to drop a zero from the end. Your code doesn't make much sense, though. If the ereg() fails, $parts is not going to have any value, so why are you referencing $part[1], $part[2], etc... ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
$parts has been removed as I found I didn't need it there, but the problem still exists. This part of code however may be causing the problem, although I thought trim only stripped white space.?. $formsave['dob'] is a session variable. I have also found now that leading 0's are also being stripped. foreach($HTTP_POST_VARS as $varname = $value) $formsave[$varname] = trim($value, 50); If it's not there then the whole script fails. B. - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: 'Beauford' [EMAIL PROTECTED]; 'PHP General' [EMAIL PROTECTED] Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob], $parts)) { $error[dob] = *; $message[dob] = Invalid date format!; $dob = \$parts[3]-$parts[2]-$parts[1]\; } So is $formsave['dob'] being changed before you get to this code, causing the check to fail? What else are you doing with $formsave['dob']? Nothing here is going to cause it to drop a zero from the end. Your code doesn't make much sense, though. If the ereg() fails, $parts is not going to have any value, so why are you referencing $part[1], $part[2], etc... ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
This is what I get when I echo $formsave[dob] - 9/09/199. It was inputted as 09/09/1990. B. - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: 'Beauford' [EMAIL PROTECTED]; 'PHP General' [EMAIL PROTECTED] Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob], $parts)) { $error[dob] = *; $message[dob] = Invalid date format!; $dob = \$parts[3]-$parts[2]-$parts[1]\; } So is $formsave['dob'] being changed before you get to this code, causing the check to fail? What else are you doing with $formsave['dob']? Nothing here is going to cause it to drop a zero from the end. Your code doesn't make much sense, though. If the ereg() fails, $parts is not going to have any value, so why are you referencing $part[1], $part[2], etc... ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
Just some more information. It appears that the session variable $formsave[dob] is causing the problem. If I echo the input $_POST['dob'] it shows correctly, but when it's put into $formsave[dob] the leading and ending 0's are being stripped. B. - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: 'Beauford' [EMAIL PROTECTED]; 'PHP General' [EMAIL PROTECTED] Sent: Sunday, March 30, 2003 2:28 PM Subject: RE: [PHP] Ereg question I am using ereg to validate the format of a date entry (mm/dd/yy), but if the year ends in a 0, it is being stripped and as such produces an error. So 1990 would be 199. The dob is being inputted by a form Here is my code: if (!ereg(^([0-9]{2})/([0-9]{2})/([0-9]{4})$, $formsave[dob], $parts)) { $error[dob] = *; $message[dob] = Invalid date format!; $dob = \$parts[3]-$parts[2]-$parts[1]\; } So is $formsave['dob'] being changed before you get to this code, causing the check to fail? What else are you doing with $formsave['dob']? Nothing here is going to cause it to drop a zero from the end. Your code doesn't make much sense, though. If the ereg() fails, $parts is not going to have any value, so why are you referencing $part[1], $part[2], etc... ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ereg question
I thought trim only stripped white space.?. $formsave['dob'] is a session variable. I have also found now that leading 0's are also being stripped. foreach($HTTP_POST_VARS as $varname = $value) $formsave[$varname] = trim($value, 50); If it's not there then the whole script fails. Why do you have the 50 there in the trim() function? That's what's causing your problems. You're removing all fives and zeros from the beginning and end of your string, along with any white space. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
On Monday 31 March 2003 04:15, Beauford wrote: Just some more information. It appears that the session variable $formsave[dob] is causing the problem. If I echo the input $_POST['dob'] it shows correctly, but when it's put into $formsave[dob] the leading and ending 0's are being stripped. Having read the whole thread it seems that you're only disclosing information when it's been totured out of you :) May I suggest that in order to save yourself and other people's time that you give FULL and ACCURATE information. For example, at the start of the thread you're pinning the blame on your ereg, then you're saying the session variable is the problem. Only after it has been pointed out to you that what you say you're doing cannot possibly have the effect that you say you're seeing, do you finally disclose that you're using trim() on the vital variables. Put simply, if you had posted your full and unadulterated code right from the start then this thread should/would/could have been resolved in about 2 posts. Saving time and frustration for everyone involved. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Bit off more than my mind could chew, Shower or suicide, what do I do? -- Julie Brown, Will I Make it Through the Eighties? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
I posted the information as I had it. I had no idea what the problem was and posted the information I thought was FULL and ACCURATE - if this isn't good enough - then maybe I'll look for another list where people are a little more forgiving of new users. Remember, you were in my shoes once. B. - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, March 30, 2003 11:20 PM Subject: Re: [PHP] Ereg question On Monday 31 March 2003 04:15, Beauford wrote: Just some more information. It appears that the session variable $formsave[dob] is causing the problem. If I echo the input $_POST['dob'] it shows correctly, but when it's put into $formsave[dob] the leading and ending 0's are being stripped. Having read the whole thread it seems that you're only disclosing information when it's been totured out of you :) May I suggest that in order to save yourself and other people's time that you give FULL and ACCURATE information. For example, at the start of the thread you're pinning the blame on your ereg, then you're saying the session variable is the problem. Only after it has been pointed out to you that what you say you're doing cannot possibly have the effect that you say you're seeing, do you finally disclose that you're using trim() on the vital variables. Put simply, if you had posted your full and unadulterated code right from the start then this thread should/would/could have been resolved in about 2 posts. Saving time and frustration for everyone involved. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Bit off more than my mind could chew, Shower or suicide, what do I do? -- Julie Brown, Will I Make it Through the Eighties? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
On Monday 31 March 2003 13:58, Beauford wrote: I posted the information as I had it. I had no idea what the problem was and posted the information I thought was FULL and ACCURATE - Full and accurate if taken literally are absolute terms and are objective not subjective. if this isn't good enough - then maybe I'll look for another list where people are a little more forgiving of new users. Remember, you were in my shoes once. Jeez, my suggestion was to make it easier for others to help you. If you insist you can always continue to post your question in installments (don't forget a teaser to whet people's appetite for the next episode). And yes, you can also look for another list if you want. These are all your choices. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Things are not always what they seem. -- Phaedrus */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
This likely won't get through, but if it does. Post a real address so these conversations don't go through the list. I mean I'm already a burden to the list as it is. B. - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 31, 2003 1:36 AM Subject: Re: [PHP] Ereg question On Monday 31 March 2003 13:58, Beauford wrote: I posted the information as I had it. I had no idea what the problem was and posted the information I thought was FULL and ACCURATE - Full and accurate if taken literally are absolute terms and are objective not subjective. if this isn't good enough - then maybe I'll look for another list where people are a little more forgiving of new users. Remember, you were in my shoes once. Jeez, my suggestion was to make it easier for others to help you. If you insist you can always continue to post your question in installments (don't forget a teaser to whet people's appetite for the next episode). And yes, you can also look for another list if you want. These are all your choices. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Things are not always what they seem. -- Phaedrus */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg question
Beauford, Jason, Build a bridge and get over it already sheeesh TYVMIA Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg sass
I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why?
Re: [PHP] Ereg sass
try two backslashes to escape php special characters - Original Message - From: Liam Gibbs [EMAIL PROTECTED] To: php list [EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 12:33 AM Subject: [PHP] Ereg sass I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg sass
try two backslashes to escape php special characters Tried that with the same result. I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ereg sass[Scanned]
Try [A-Za-z0-9_\-\.]* -Original Message- From: Liam Gibbs [mailto:[EMAIL PROTECTED] Sent: 18 March 2003 08:52 To: php list Subject: Re: [PHP] Ereg sass[Scanned] try two backslashes to escape php special characters Tried that with the same result. I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg sass
It's seeing the - as a range identifier, escape it to get the literal hyphen. How about this: [a-zA-Z0-9_\-.]* In my tests, the period didn't need to be escaped with the \. HTH, Jason k Larson Liam Gibbs wrote: I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg sass
At 10:36 18.03.2003, Jason k Larson said: [snip] It's seeing the - as a range identifier, escape it to get the literal hyphen. How about this: [a-zA-Z0-9_\-.]* In my tests, the period didn't need to be escaped with the \. [snip] The period is a regex placeholder for any character. Thus it will match a period, but also a #, a @, and everything that's not allowed in the planned regex. By escaping the period you're changing the meaning from any character to or a period (in this context) so I believe that's what you want to do. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg sass
If you want to look for a dash (-), you always place it last in the brackets, other wise the regex machine will be looking for a range. So just move the - to the last character. [A-Za-z0-9_.-]* ---John Holmes... - Original Message - From: Liam Gibbs [EMAIL PROTECTED] To: php list [EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 3:33 AM Subject: [PHP] Ereg sass I'm not sure why, but I can't include a period in my eregi statement: [A-Za-z0-9_-.]* For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in /home/website/public_html/Functions.inc on line 27 The same goes for [A-Za-z0-9_-\.]* Anyone know why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg usage
Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. Many thanks Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg usage
At 16:18 16.02.2003, Peter Gumbrell said: [snip] Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. [snip] You're missing the -1 part in your expression: ^ Your string begins [A-H]* with no or more letters from A to H ([0-9]+)followed by one or more digits (grouped) -followed by a dash $ and the end or the string Your pattern would match C12-, but not C12-1. If you only need the C12, your pattern should look something like '^([A-H]*[0-9]+)-' to return the complete letter/digit sequence at the beginning of the string, up to (but not including) the dash. Omitting the '$' (string end) character allows for anything after the dash. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg usage
The problem is that it's looking for hyphen, - , immediately preceeding the end. Remove the $. - Original Message - From: Peter Gumbrell [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Sunday, February 16, 2003 9:18 AM Subject: [PHP] ereg usage Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. Many thanks Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg.
What's wrong with the following regular expression? As far as I can se, only alphabetic characters including the special swedish ones, should be let through, but whatever character passed on in $_REQUEST['f_name'] passes the test? if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) { error(Your first name should be between 4 and 20 alphabetic characters); } The next one, used to check valid birthday dates, work. And I can't see where they differ! if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday'])) Br, Anders -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg.
^ is not in this case Try if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) { Added the $ at the end else the could be more then 20 chars Greetz At 17:20 18-12-02 +0100, Anders Thoresson wrote: What's wrong with the following regular expression? As far as I can se, only alphabetic characters including the special swedish ones, should be let through, but whatever character passed on in $_REQUEST['f_name'] passes the test? if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) { error(Your first name should be between 4 and 20 alphabetic characters); } The next one, used to check valid birthday dates, work. And I can't see where they differ! if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday'])) Br, Anders -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg.
At 17:26 18-12-02 +0100, Wico de Leeuw wrote: ^ is not in this case Cancel that, i don't think thats true anyway if(!ereg(^[a-zA-ZåÅäÄöÖ]{4,20}\$, $_REQUEST['f_name'])) { Should work i think Gr, Try if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) { Added the $ at the end else the could be more then 20 chars Greetz At 17:20 18-12-02 +0100, Anders Thoresson wrote: What's wrong with the following regular expression? As far as I can se, only alphabetic characters including the special swedish ones, should be let through, but whatever character passed on in $_REQUEST['f_name'] passes the test? if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) { error(Your first name should be between 4 and 20 alphabetic characters); } The next one, used to check valid birthday dates, work. And I can't see where they differ! if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday'])) Br, Anders -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg.
^ is only NOT when it's the first character within brackets, [ and ]. Also, don't escape the $ at the end if you really want it to match the end of the string. Right now your regular expression is matching a literal dollar sign. As for the original question, it looks correct, providing you can have those swedish characters in the brackets. What if you just simplify things and make your ereg look to match a single one of those swedish chacters? Will it validate correctly if that's all you pass? Play with taking them in and out and see what works. ---John Holmes... - Original Message - From: Wico de Leeuw [EMAIL PROTECTED] To: Anders Thoresson [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, December 18, 2002 11:26 AM Subject: Re: [PHP] ereg. ^ is not in this case Try if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) { Added the $ at the end else the could be more then 20 chars Greetz At 17:20 18-12-02 +0100, Anders Thoresson wrote: What's wrong with the following regular expression? As far as I can se, only alphabetic characters including the special swedish ones, should be let through, but whatever character passed on in $_REQUEST['f_name'] passes the test? if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) { error(Your first name should be between 4 and 20 alphabetic characters); } The next one, used to check valid birthday dates, work. And I can't see where they differ! if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday'])) Br, Anders -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg.
Instead of: (!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) Try: (!ereg(^[a-zA-ZåÅäÄöÖ]{4,20}$, $_REQUEST['f_name'])) (You don't need the brackets unless you're wanting to get the output of the matches, which in this case, it doesn't look as though you do) Better still: (!preg_match(!^[a-zåÅäÄöÖ]{4,20}$!is, $_REQUEST['f_name'])) James 1lt John W. Holmes [EMAIL PROTECTED] wrote in message 002301c2a6b3$a5a695f0$a629089b@TBHHCCDR">news:002301c2a6b3$a5a695f0$a629089b@TBHHCCDR... ^ is only NOT when it's the first character within brackets, [ and ]. Also, don't escape the $ at the end if you really want it to match the end of the string. Right now your regular expression is matching a literal dollar sign. As for the original question, it looks correct, providing you can have those swedish characters in the brackets. What if you just simplify things and make your ereg look to match a single one of those swedish chacters? Will it validate correctly if that's all you pass? Play with taking them in and out and see what works. ---John Holmes... - Original Message - From: Wico de Leeuw [EMAIL PROTECTED] To: Anders Thoresson [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, December 18, 2002 11:26 AM Subject: Re: [PHP] ereg. ^ is not in this case Try if(!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) { Added the $ at the end else the could be more then 20 chars Greetz At 17:20 18-12-02 +0100, Anders Thoresson wrote: What's wrong with the following regular expression? As far as I can se, only alphabetic characters including the special swedish ones, should be let through, but whatever character passed on in $_REQUEST['f_name'] passes the test? if(!ereg((^[a-zA-ZåÅäÄöÖ]{4,20}), $_REQUEST['f_name'])) { error(Your first name should be between 4 and 20 alphabetic characters); } The next one, used to check valid birthday dates, work. And I can't see where they differ! if(!ereg(([0-9]{4})-([0-9]{2})-([0-9]{2}), $_REQUEST['birthday'])) Br, Anders -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg headache: got an Aspirin
Finally, I found y answer to my ereg/grep question. Thanks to all those who took a stab at it. You led me to the answer. For all those interested in reg-parsing comma-delimited lists, here is what I searched for: '^INPUT TYPE = \HIDDEN\ NAME = \numbers\ VALUE = \[0-9,\]*[\,] . $numbertosearch . [\,][0-9,\]*$' It was much simpler than I thought it would be. Thanks again! __ Do you Yahoo!? Yahoo! Mail Plus Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg headache
I have a real problem that I can't seem to figure out. I need an ereg pattern to search for a certain string (below). All this is being shelled to a Unix grep command because I'm looking this up in very many files. I've made myself a INPUT TYPE=HIDDEN tag that contains in the value attribute a list of comma-delimited numbers. I need to find if a certain number is in these tags (and each file contains one tag). I need an ereg statement that will let me search these lines to see if a number exists, obviously in the beginning or the end or the middle or if it's the only number in the list. Here's what I mean (searching for number 1): INPUT TYPE = HIDDEN NAME = numbers VALUE = 1,2,3,4,5 //beginning INPUT TYPE = HIDDEN NAME = numbers VALUE = 0,1,2,3,4,5 //middle INPUT TYPE = HIDDEN NAME = numbers VALUE = 5,4,3,2,1 //end INPUT TYPE = HIDDEN NAME = numbers VALUE = 1 //only This is frustrating me, because each solution I come up with doesn't work. Here is my grep/ereg statement so far: $commanumberbeginning = [[0-9]+,]*; //this allows 0 or more numbers before it, and if there are any, they must have 1 or more digits followed by a comma $commanumberend = [,[0-9]+]*; // this allows 0 or more numbers after it, and if there are any, they must have a comma followed by 1 or more digits $ereg-statement=$commanumberbeginning . $numbertosearchfor . $commanumberbeginning; //$numbertosearchfor will be obtained through a select control in a form grep 'INPUT TYPE = HIDDEN NAME = numbers VALUE = $ereg-statement' *.html This problem is kicking my butt. Any help? __ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg (Why, Does sort of work)?
I'm comparing the values of a check box, against another form field, and it sort of works, but I don't understand why (A better solution? is listed below it? TIA, David Jackson --- And part of the HTML Form: --- tdbAccount Type:/b/td tdAsset/tdtdinput type=radio name=transid value=1000/td tdLiability/tdtdinput type=radio name=transid value=2000/td input type=text name=coa_acct size=5 maxlength=5 -- Here's the one that's puzzling me: -- if ( ereg(^1,$_POST['transid'])== ereg(^1,$_POST['coa_acct'])): echo $_POST['coa_acct']; else : echo Get off you Asset!; exit; endif; --- The better solution using substrings? --- if ( substr($_POST['transid'],0,1)== substr($_POST['coa_acct'],0,1)): echo $_POST['coa_acct']; else : echo Get off you Asset!; exit; endif; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg help
Hey all, I've been fighting this all night, I need a bit of help. I have a string like. #21-935 Item Description: $35.95 Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits, and the price could be a combination of 1,2,3 . 2 digits. I want to chop that string into Part # / Description / Price. I'd appreciate any help, I know this is probably real simple :) Thanks in advance. Thanks, William Glenn Import Parts Plus http://www.importpartsplus.com
Re: [PHP] Ereg help
?php $s = #12-3456 The Item description $35.43; $qq = ereg(#([0-9]*-[0-9]*) ([a-zA-Z0-9 ]*) \\$([0-9]{1,3}\.[0-9]{2}), $s,$a); $val = $a[1]./.$a[2]./.$a[3]; print $val; ? - Original Message - From: William Glenn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 25, 2002 10:34 AM Subject: [PHP] Ereg help Hey all, I've been fighting this all night, I need a bit of help. I have a string like. #21-935 Item Description: $35.95 Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits, and the price could be a combination of 1,2,3 . 2 digits. I want to chop that string into Part # / Description / Price. I'd appreciate any help, I know this is probably real simple :) Thanks in advance. Thanks, William Glenn Import Parts Plus http://www.importpartsplus.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg Help
Hi William, try this: ^(#[0-9]{2}-[0-9]{2,4} Item Description: [\$][0-9]{1,3}[\.][0-9]{2})$ I've just been putting a number of expressions together for validation myself. Regards, Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg
Hoping someone can help me here. I'm working with someone else's code and I'm not familiar with ereg_replace(), can someone provide me an alternative to the following? ereg_replace([^a-z0-9._], , ereg_replace ( , _, ereg_replace(%20, _, strtolower($original_name; Basically, I want to enter $original_name and have it come out $new_name, converting all spaces to underscores, upper to lowercase, and whatever that first line does. :) I've read through the manual and what I got was that preg_replace() is probably faster... Anyhow, I looked up preg_replace() and as a newbie to PHP, the given examples look like a language all their own. Thanks, Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg() not matching same text each time script is run...
Okay...I'm really at a loss for this... (PHP 4.0.6 on Redhat Linux) I've written a little script that shows the top referrers for http://www.falkware.com. Problem is...the script is supposed to take www.domain.com and strip out only the domain to show. It does this, but only some of the time. I can't figure out a pattern to it, but sometimes the ereg will match domain and sometimes it won't... ?? The data is always the same because it's coming from a database. what gives? Here is the code. This is the same exact code that is running on http://www.falkware.com right now. Referrer script is on left hand side near the bottom. Refresh the screen and you'll see how it changes (maybe?). You can see I've added in some HTML comments to echo out what the site from the database is, and what was matched. If anyone can help me out, it's greatly appreciated. I must be going crazy or something You can see the same question and code at http://forums.devshed.com/showthread.php?s=threadid=34534forumid=5. The PHP code has syntax highlighting on it, so it may be easier to read there. The lines in question are: eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2); $name = $match2[1]; How, if $row[site] is the same because it's pulled from a database, can the ereg match the domain some of the time, and not match it during other times...? PHP: - //Display table of referers $referer_query = SELECT ID, site, count, DATE_FORMAT(last_visit,'%c/%e/%y %k:%i') AS last_visit, count/(TO_DAYS(NOW()) - TO_DAYS(first_visit)) AS visits_per_day FROM $table ORDER BY count DESC LIMIT . (int)$num_sites; $referer_result = DB_query($referer_query); $returned_rows = DB_numRows($referer_result); if($returned_rows 0) { if($_CST_VERBOSE) { COM_errorLog( Displaying top $returned_rows Sites , 1); } $retval .= table border='0' cellspacing='0' cellpadding='0' align='center' bordercolor='#afae8b' width='98%' tr td align=centerbfont face='verdana' size='1' u#/u /font/b/td td align=centerbfont face='verdana' size='1' uSite/u /font/b/td td align=centerbfont face='verdana' size='1' uHits/u /font/b/td /tr ; $site_count = 1; while($row = DB_fetchArray($referer_result)) { if($_CST_VERBOSE) { COM_errorLog( Displaying Site #$site_count, $row[site] , 1); } unset($match2); $retval .= !-- Row[site] == . $row[site] . --; eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2); $name = $match2[1]; $retval .= !-- Name matched == . $name . --; if(strlen($name) == 0) { $name = $row[site]; } $link = http://; . $row[site] . /; $retval .= tr td align=centerfont face='tahoma' size='1' color='black'strong $site_count /strong/font/td td align=center a href='$link' target='_blank'font face='verdana' size='1'strong $name /strong/font/a /td td align='center'font face='verdana' size='1'strong $row[count] /strong/font/td /tr ; $site_count++; if($show_time == 1) { $retval .= trtd colspan='3' align='right'font face='verdana' size='1' color='#99'Last: $row[last_visit]/td/tr; } if($show_posts == 1) { if($row[visits_per_day] = 0) { $row[visits_per_day] = $row[count]; } $retval .= trtd colspan='3' align='right'font face='verdana' size='1' color='#99'Per Day: $row[visits_per_day]/td/tr; } } $retval .= /table; } else { $retval .= No referers yet.; } if($_CST_VERBOSE) { COM_errorLog( Leaving phpblock_top_referer in lib-custom.php , 1); } return $retval; When I run the page and look at the source, one time I'll get !-- Row[site] == www.luclinks.com --!-- Name matched == -- for the comments, and the next time it's run I'll get: !-- Row[site] == www.luclinks.com --!-- Name matched == luclinks -- ?? Like I said, I can't find a pattern to it though. I'm going to try out some other regular expressions...maybe that'll do the trick. Suggestions are welcome. Here is a sample of the table that the data is coming from: code:--- -- SELECT * FROM referer ORDER BY count DESC LIMIT 10; ID Site Count First_Visit Last_Visit IP 8
RE: [PHP] ereg() not matching same text each time script is run...
Someone gave me the preg_match equivalent preg_match( '/([-_a-z]+)\.([a-z]+)$/i', $row['site'], $match2 ); I tried that and it took care of the problem, as far as I can tell. To me, that narrows it down to a problem (bug?) with ereg... anyone else have any ideas? ---John Holmes... -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 6:01 PM To: [EMAIL PROTECTED] Subject: [PHP] ereg() not matching same text each time script is run... Okay...I'm really at a loss for this... (PHP 4.0.6 on Redhat Linux) I've written a little script that shows the top referrers for http://www.falkware.com. Problem is...the script is supposed to take www.domain.com and strip out only the domain to show. It does this, but only some of the time. I can't figure out a pattern to it, but sometimes the ereg will match domain and sometimes it won't... ?? The data is always the same because it's coming from a database. what gives? Here is the code. This is the same exact code that is running on http://www.falkware.com right now. Referrer script is on left hand side near the bottom. Refresh the screen and you'll see how it changes (maybe?). You can see I've added in some HTML comments to echo out what the site from the database is, and what was matched. If anyone can help me out, it's greatly appreciated. I must be going crazy or something You can see the same question and code at http://forums.devshed.com/showthread.php?s=threadid=34534forumid=5. The PHP code has syntax highlighting on it, so it may be easier to read there. The lines in question are: @eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2); $name = $match2[1]; How, if $row[site] is the same because it's pulled from a database, can the ereg match the domain some of the time, and not match it during other times...? PHP: - //Display table of referers $referer_query = SELECT ID, site, count, DATE_FORMAT(last_visit,'%c/%e/%y %k:%i') AS last_visit, count/(TO_DAYS(NOW()) - TO_DAYS(first_visit)) AS visits_per_day FROM $table ORDER BY count DESC LIMIT . (int)$num_sites; $referer_result = DB_query($referer_query); $returned_rows = DB_numRows($referer_result); if($returned_rows 0) { if($_CST_VERBOSE) { COM_errorLog( Displaying top $returned_rows Sites , 1); } $retval .= table border='0' cellspacing='0' cellpadding='0' align='center' bordercolor='#afae8b' width='98%' tr td align=centerbfont face='verdana' size='1' u#/u /font/b/td td align=centerbfont face='verdana' size='1' uSite/u /font/b/td td align=centerbfont face='verdana' size='1' uHits/u /font/b/td /tr ; $site_count = 1; while($row = DB_fetchArray($referer_result)) { if($_CST_VERBOSE) { COM_errorLog( Displaying Site #$site_count, $row[site] , 1); } unset($match2); $retval .= !-- Row[site] == . $row[site] . --; @eregi(([-_a-z]+)\.([a-z]+)$,$row[site],$match2); $name = $match2[1]; $retval .= !-- Name matched == . $name . --; if(strlen($name) == 0) { $name = $row[site]; } $link = http://; . $row[site] . /; $retval .= tr td align=centerfont face='tahoma' size='1' color='black'strong $site_count /strong/font/td td align=center a href='$link' target='_blank'font face='verdana' size='1'strong $name /strong/font/a /td td align='center'font face='verdana' size='1'strong $row[count] /strong/font/td /tr ; $site_count++; if($show_time == 1) { $retval .= trtd colspan='3' align='right'font face='verdana' size='1' color='#99'Last: $row[last_visit]/td/tr; } if($show_posts == 1) { if($row[visits_per_day] = 0) { $row[visits_per_day] = $row[count]; } $retval .= trtd colspan='3' align='right'font face='verdana' size='1' color='#99'Per Day: $row[visits_per_day]/td/tr; } } $retval .= /table; } else { $retval .= No referers yet.; } if($_CST_VERBOSE) { COM_errorLog( Leaving phpblock_top_referer in lib-custom.php , 1); } return $retval; When I run the page and look at the source, one time I'll get !-- Row[site] == www.luclinks.com --!-- Name matched == -- for the comments, and the next time
[PHP] ereg size limit???
I am trying to validate my input with ereg but I get the error Warning: REG_BADBR when I try over 255 characters. Is there anyway around this? Works = if(eregi('^[A-Za-z]{1,255}$', test sentence)) echo valid input; Doesn't Work if(eregi('^[A-Za-z]{1,256}$', test sentence)) echo valid input; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ereg ()
Hi, I'm new with RegEx and I would like to use them to validate my forms entries submitted to the server. My question is how can I verify with the regex that a string is - at least 7 chars - contains Chars and Nums - may contains some special chars (ex : % ! : ; , )but not in first or last position . Regards Laurent Drouet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg ()
On Tuesday, April 16, 2002, at 08:49 AM, [EMAIL PROTECTED] wrote: I'm new with RegEx and I would like to use them to validate my forms entries submitted to the server. My question is how can I verify with the regex that a string is - at least 7 chars - contains Chars and Nums - may contains some special chars (ex : % ! : ; , )but not in first or last position . I'm assuming that by Chars you mean uppercase/lowercase letters? Numbers are characters too, I thought. preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string); The above regex will only match a string that begins with A-Z or a-z or 0-9, then any number of characters that are in the middle character class, then a final A-Z or a-z or 0-9. I think. Try it out, that's untested. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg ()
Thanks for this answer. But how can i test if i actually have numbers AND letters ? Laurent Drouet Erik Price pricee@hhbrow To: [EMAIL PROTECTED] n.com cc: [EMAIL PROTECTED] Subject: Re: [PHP] Ereg () 16/04/02 15:44 On Tuesday, April 16, 2002, at 08:49 AM, [EMAIL PROTECTED] wrote: I'm new with RegEx and I would like to use them to validate my forms entries submitted to the server. My question is how can I verify with the regex that a string is - at least 7 chars - contains Chars and Nums - may contains some special chars (ex : % ! : ; , )but not in first or last position . I'm assuming that by Chars you mean uppercase/lowercase letters? Numbers are characters too, I thought. preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string); The above regex will only match a string that begins with A-Z or a-z or 0-9, then any number of characters that are in the middle character class, then a final A-Z or a-z or 0-9. I think. Try it out, that's untested. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ereg ()
On Tuesday, April 16, 2002, at 09:51 AM, [EMAIL PROTECTED] wrote: Thanks for this answer. But how can i test if i actually have numbers AND letters ? preg_match('/([A-Za-z].*[\d]|[\d].*[A-Za-z]/', $string); Untested, but in theory should work. On Tuesday, April 16, 2002, at 08:49 AM, [EMAIL PROTECTED] wrote: I'm new with RegEx and I would like to use them to validate my forms entries submitted to the server. My question is how can I verify with the regex that a string is - at least 7 chars - contains Chars and Nums - may contains some special chars (ex : % ! : ; , )but not in first or last position . I'm assuming that by Chars you mean uppercase/lowercase letters? Numbers are characters too, I thought. preg_match('/^[A-Za-z0-9][A-Za-z0-9%!:;,]{5,}[A-Za-z0-9]$/', $string); The above regex will only match a string that begins with A-Z or a-z or 0-9, then any number of characters that are in the middle character class, then a final A-Z or a-z or 0-9. I think. Try it out, that's untested. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg-digits only...
How do I check a string for it to only contain numbers? if(!ereg(([0-9]+),$string)){ print It contains characters other than numbers; }else{ print Only numbers; } Can anyone give some feedback... regards, Bart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg-digits only...
if ((int($string)==($string)) ($string0)) {then positive integer} not sure exactly, but try Valentin Petruchek (aki Zliy Pes) *** Cut the beginning *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: B. Verbeek [EMAIL PROTECTED] To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 1:04 PM Subject: [PHP] ereg-digits only... How do I check a string for it to only contain numbers? if(!ereg(([0-9]+),$string)){ print It contains characters other than numbers; }else{ print Only numbers; } Can anyone give some feedback... regards, Bart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg-digits only...
if ((int($string)==($string)) ($string0)) {then positive integer} not sure exactly, but try Why not use the RE's? I usually use preg_* so I'll give the example using these... if (preg_match (/^\d+$/, $string)) { print (Yep... Only digits.); } else { prnt (Noop! There are non-digit characters...); } -- * RzE: -- -- Renze Munnik -- DataLink BV -- -- E: [EMAIL PROTECTED] -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- Netherlands -- -- http://www.datalink.nl -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ereg-digits only...
That wouldn't work! 1) You meant to write: if (((int)$string==$string) ($string0)) 2) (int)'5a' == 5, so this formula would result is 5a == 5! --Daniel -Original Message- From: val petruchek [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 6:22 AM To: [EMAIL PROTECTED] Cc: PHP Subject: Re: [PHP] ereg-digits only... if ((int($string)==($string)) ($string0)) {then positive integer} not sure exactly, but try Valentin Petruchek (aki Zliy Pes) *** Cut the beginning *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: B. Verbeek [EMAIL PROTECTED] To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 1:04 PM Subject: [PHP] ereg-digits only... How do I check a string for it to only contain numbers? if(!ereg(([0-9]+),$string)){ print It contains characters other than numbers; }else{ print Only numbers; } Can anyone give some feedback... regards, Bart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg-digits only...
as a said before i'm not sure; my idea was to use type casting instead of eregi; anyone can develop it into smart solution; i am out of time now for this developing so can suggest idea only Valentin Petruchek (aki Zliy Pes) *** cUT THE BEGINNING *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: Daniel Kushner [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: PHP [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 4:00 PM Subject: RE: [PHP] ereg-digits only... That wouldn't work! 1) You meant to write: if (((int)$string==$string) ($string0)) 2) (int)'5a' == 5, so this formula would result is 5a == 5! --Daniel -Original Message- From: val petruchek [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 6:22 AM To: [EMAIL PROTECTED] Cc: PHP Subject: Re: [PHP] ereg-digits only... if ((int($string)==($string)) ($string0)) {then positive integer} not sure exactly, but try Valentin Petruchek (aki Zliy Pes) *** Cut the beginning *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] - Original Message - From: B. Verbeek [EMAIL PROTECTED] To: Php-Db-Help (E-mail) [EMAIL PROTECTED]; Php-General (E-mail) [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 1:04 PM Subject: [PHP] ereg-digits only... How do I check a string for it to only contain numbers? if(!ereg(([0-9]+),$string)){ print It contains characters other than numbers; }else{ print Only numbers; } Can anyone give some feedback... regards, Bart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg-digits only...
On Tue, 2002-02-12 at 03:04, B. Verbeek wrote: How do I check a string for it to only contain numbers? if(!ereg(([0-9]+),$string)){ print It contains characters other than numbers; }else{ print Only numbers; } Can anyone give some feedback... regards, Bart Sure, try is_numeric(): http://www.php.net/is_numeric Hope this helps, Torben -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg
Hi there! Is there any mean to tell PHP to use ereg etc. greedy? Thanx, Kiko - It's not a bug, it's a feature. [.nfq] christoph starkmann tel.: 0821 / 56 97 94 34 fax.: 0821 / 56 97 94 38 http://www.fh-augsburg.de/~kiko ICQ: 100601600 - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ereg et all
hi, is there a simple way to replace an occurence of a string, into another, maintaing capital positions... Like: $str = This equals this equals tHis; and I wanna replace all occurences of this in that, that the result will be: $str = That equals that equals That; Edward -- 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 et all
try: eregi_replace(this,that,This equals this equals tHis); -Original Message- From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 3:40 PM To: [EMAIL PROTECTED] Subject: [PHP] ereg et all hi, is there a simple way to replace an occurence of a string, into another, maintaing capital positions... Like: $str = This equals this equals tHis; and I wanna replace all occurences of this in that, that the result will be: $str = That equals that equals That; Edward -- 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 et all
that is not what I meant... I want the cases to remain... - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:47 PM Subject: RE: [PHP] ereg et all try: eregi_replace(this,that,This equals this equals tHis); -Original Message- From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 3:40 PM To: [EMAIL PROTECTED] Subject: [PHP] ereg et all hi, is there a simple way to replace an occurence of a string, into another, maintaing capital positions... Like: $str = This equals this equals tHis; and I wanna replace all occurences of this in that, that the result will be: $str = That equals that equals That; Edward -- 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]
Re: [PHP] ereg et all
I'm not sure why you wanted the last word tHis to be changed to That (with a capital)... can you explain further? Jeff At 10:52 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote: that is not what I meant... I want the cases to remain... - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:47 PM Subject: RE: [PHP] ereg et all try: eregi_replace(this,that,This equals this equals tHis); -Original Message- From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 3:40 PM To: [EMAIL PROTECTED] Subject: [PHP] ereg et all hi, is there a simple way to replace an occurence of a string, into another, maintaing capital positions... Like: $str = This equals this equals tHis; and I wanna replace all occurences of this in that, that the result will be: $str = That equals that equals That; Edward -- 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 et all
Oh, that was a typo... sorry... it should be: This equals this equals tHis - That equals that equals tHat Edward - Original Message - From: Jeff Sheltren [EMAIL PROTECTED] To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:56 PM Subject: Re: [PHP] ereg et all I'm not sure why you wanted the last word tHis to be changed to That (with a capital)... can you explain further? Jeff At 10:52 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote: that is not what I meant... I want the cases to remain... - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Edward van Bilderbeek - Bean IT' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:47 PM Subject: RE: [PHP] ereg et all try: eregi_replace(this,that,This equals this equals tHis); -Original Message- From: Edward van Bilderbeek - Bean IT [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 3:40 PM To: [EMAIL PROTECTED] Subject: [PHP] ereg et all hi, is there a simple way to replace an occurence of a string, into another, maintaing capital positions... Like: $str = This equals this equals tHis; and I wanna replace all occurences of this in that, that the result will be: $str = That equals that equals That; Edward -- 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 et all
Ahhh, ok makes more sense now. Although, I don't think that there is an easy way to do what you are asking. I think that in order to accomplish that, you will have to specify all possible cases of a string, and have a ereg_replace() statement for each of them. Jeff At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote: Oh, that was a typo... sorry... it should be: This equals this equals tHis - That equals that equals tHat Edward - Original Message - From: Jeff Sheltren [EMAIL PROTECTED] To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:56 PM Subject: Re: [PHP] ereg et all I'm not sure why you wanted the last word tHis to be changed to That (with a capital)... can you explain further? Jeff -- 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 et all
hmm, that's not what i wanted to hear :-))) e.g. try doing that for the word: transparancy looots of different possibilities then... Edward - Original Message - From: Jeff Sheltren [EMAIL PROTECTED] To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 11:06 PM Subject: Re: [PHP] ereg et all Ahhh, ok makes more sense now. Although, I don't think that there is an easy way to do what you are asking. I think that in order to accomplish that, you will have to specify all possible cases of a string, and have a ereg_replace() statement for each of them. Jeff At 11:01 PM 1/31/2002 +0100, Edward van Bilderbeek - Bean IT wrote: Oh, that was a typo... sorry... it should be: This equals this equals tHis - That equals that equals tHat Edward - Original Message - From: Jeff Sheltren [EMAIL PROTECTED] To: Edward van Bilderbeek - Bean IT [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:56 PM Subject: Re: [PHP] ereg et all I'm not sure why you wanted the last word tHis to be changed to That (with a capital)... can you explain further? Jeff -- 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]