RE: [PHP] Simple RegExp Problem...
Thanks again Ernest! This will be extremely helpful to me in the near future. - Nilaab > -Original Message- > From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 22, 2002 3:23 PM > To: @ Nilaab > Cc: Php-General > Subject: RE: [PHP] Simple RegExp Problem... > > > At 21:59 22.11.2002, @ Nilaab said: > [snip] > >Thanks so much!!! It works. I didn't know I could also place extra > >characters inside the brackets to specify what I want. :) > [snip] > > The square brackets simply form a group of characters that are either > allowed ('[abc]') or not allowed ('[^abc]'). > > Instead of specifying '/[a-zA-Z]/' you have also the option of saying > '/[a-z]/i', the i modifier making the whole regex case independent. > > For deeper regex insights (esp. for the preg_xxx functions which I > personally prefer) I suggest visiting the Perl docs at > Doc:http://www.perldoc.com/perl5.8.0/pod/perlre.html > QuickIntro: http://www.perldoc.com/perl5.8.0/pod/perlrequick.html > Tutorial: http://www.perldoc.com/perl5.8.0/pod/perlretut.html > > For the PHP guyz'n gals listening - I suggest these links making it into > the PHP docs :) > > -- >>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] Simple RegExp Problem...
At 21:59 22.11.2002, @ Nilaab said: [snip] >Thanks so much!!! It works. I didn't know I could also place extra >characters inside the brackets to specify what I want. :) [snip] The square brackets simply form a group of characters that are either allowed ('[abc]') or not allowed ('[^abc]'). Instead of specifying '/[a-zA-Z]/' you have also the option of saying '/[a-z]/i', the i modifier making the whole regex case independent. For deeper regex insights (esp. for the preg_xxx functions which I personally prefer) I suggest visiting the Perl docs at Doc:http://www.perldoc.com/perl5.8.0/pod/perlre.html QuickIntro: http://www.perldoc.com/perl5.8.0/pod/perlrequick.html Tutorial: http://www.perldoc.com/perl5.8.0/pod/perlretut.html For the PHP guyz'n gals listening - I suggest these links making it into the PHP docs :) -- >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] Simple RegExp Problem...
Thanks so much!!! It works. I didn't know I could also place extra characters inside the brackets to specify what I want. :) > -Original Message- > From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 22, 2002 7:19 AM > To: @ Nilaab > Cc: Php-General > Subject: Re: [PHP] Simple RegExp Problem... > > > At 13:38 22.11.2002, @ Nilaab spoke out and said: > [snip] > >Ok, I know this is easy for most of you, and believe me I've > been searching > >and trying to learn all about regular expressions, but I can't > seem figure > >out how to allow addition of spaces between characters. > > > >$text = "Here is some text"; > > > >Here, I want to be able to match the alpha characters as well as > the spaces > >in between each word. So far I have: > > > >preg_match("/^[a-zA-Z]+$/", $text); > > > >But that only matches a single word without spaces. I would like > to try to > >stay away from ereg and use preg_match instead because I heard > preg_match is > >faster. ereg() has a way to match spaces by specifying [[:space:]], but I > >didn't get that solution to work either. How do I match $text to return > >true? > [snip] > > use > preg_match('/^[a-zA-Z\s]+$/', $text); > > \s - any [:space:] > \S - anything not [:space:] > > > -- >>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] Simple RegExp Problem...
At 13:38 22.11.2002, @ Nilaab spoke out and said: [snip] >Ok, I know this is easy for most of you, and believe me I've been searching >and trying to learn all about regular expressions, but I can't seem figure >out how to allow addition of spaces between characters. > >$text = "Here is some text"; > >Here, I want to be able to match the alpha characters as well as the spaces >in between each word. So far I have: > >preg_match("/^[a-zA-Z]+$/", $text); > >But that only matches a single word without spaces. I would like to try to >stay away from ereg and use preg_match instead because I heard preg_match is >faster. ereg() has a way to match spaces by specifying [[:space:]], but I >didn't get that solution to work either. How do I match $text to return >true? [snip] use preg_match('/^[a-zA-Z\s]+$/', $text); \s - any [:space:] \S - anything not [:space:] -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/