What does IMHO mean?
Allowing punctuation marks in regular expressions
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > PHP web-programming > Allowing punctuation marks in regular expressions 6 June 2003 02:42:22

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Allowing punctuation marks in regular expressions

Luis Lebron 6 June 2003 02:42:22
 I found the following function to test a string for alphanumeric characters

function is_alphanumeric($st­ring)
{
return (preg_match("/^[a-z0-9]+$/i­", $string));
}

How can I modify it so that it also allows punctuation marks?

thanks,

Luis R. Lebron
Add comment
Dan Joseph 5 June 2003 22:41:49 permanent link ]
 Hi,
return (preg_match("/^[a-z0-9]+$/i­", $string));

That a-z0-9 is where you can do it. Just add ! or . or ? to the end:

a-z0-9!?.

Also, if you want upper case letters, make sure you add A-Z:

A-Za-z0-9!?.

-Dan Joseph

--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Luis Lebron 5 June 2003 22:57:40 permanent link ]
 I tried adding a period to the end but a string will a period still returns
false

function is_alphanumeric($st­ring)
{
return (preg_match("/^[A-Za-z0-9.]+$/i­", $string));
}


-----Original Message-----
From: Dan Joseph [mailto:djoseph@duhq.us]
Sent: Thursday, June 05, 2003 2:42 PM
To: Php-General (E-mail)
Subject: RE: [PHP] Allowing punctuation marks in regular expressions


Hi,
return (preg_match("/^[a-z0-9]+$/i­", $string));

That a-z0-9 is where you can do it. Just add ! or . or ? to the
end:

a-z0-9!?.

Also, if you want upper case letters, make sure you add A-Z:

A-Za-z0-9!?.

-Dan Joseph

--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php
Add comment
Leif K-Brooks 5 June 2003 23:04:22 permanent link ]
 It's using the case-insensitive switch.

Dan Joseph wrote:
Also, if you want upper case letters, make sure you add A-Z:


--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.



--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
John W. Holmes 6 June 2003 02:42:22 permanent link ]
 
I tried adding a period to the end but a string will a period still> returns> false>
function is_alphanumeric($st­ring)> {> return (preg_match("/^[A-Za-z0-9.]+$/i­", $string));> }

No it doesn't. It's not allowing spaces, though... Is that the problem?

---John W. Holmes...

Amazon Wishlist: http://www.amazon.c­om/o/registry/3BEXC8­4AB3A5E

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


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > PHP web-programming > Allowing punctuation marks in regular expressions 6 June 2003 02:42:22

see also:
list online
Network drives, IIS, and PHP
Adduser in PHP
пройди тесты:
see also:
MY SISTER'S WORDS TO ME AFTER MANY MANY…
ONE VERSE THAT MADE ME LOVE MY SISTER…
HERE IS A STORY OF OUR LIVES!!!

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .