SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Regular Expressions
-
Nov 5, 2001, 10:43 #1
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Regular Expressions
Hi,
I'm trying to figure a method of disallowing certain characters in a variable.
Say, the list:
#&;´'\"|*?~<>^()[]{}$
How do I do that? Thanks for your help."Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
Nov 5, 2001, 16:38 #2
- Join Date
- Aug 2001
- Location
- Kent, Ohio
- Posts
- 367
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:/* Let's assume that your variable is called $foo */ if (preg_match("/^[^#&;´'\"|*?~<>\^()[\]{}$]+$/",$foo)) { //do bad variable format stuff // // } else { //format accepted //do other stuff here }
-
Nov 5, 2001, 20:18 #3
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey Thanks! Great!
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
Bookmarks