Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
preg_match and ilegal chars at start and end of string
Old 11-02-2007, 06:19 AM preg_match and ilegal chars at start and end of string
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
Hi

Ive just started using preg_match to validate some form info, and ive become very lost and confused. is there a good tutorial on using preg_match that anyone can point me to. Basically my problem is this -

PHP Code:
if(preg_match("/[^a-zA-Z0-9\ \'\@\!\£\$\%\&\*\(]+$/",$string)) 
above is my preg_match function, the issue with it is that it will only catch an ilegal character if it is the last in the string. clearly this is of no use as a form validator but i have no clue as to why it is happening. all thoughts welcome.

mark
hiptobesquare is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-02-2007, 09:03 AM Re: preg_match and ilegal chars at start and end of string
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
this is a bit helpful - http://zez.org/article/articleview/11/1/
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Old 11-02-2007, 11:14 PM Re: preg_match and ilegal chars at start and end of string
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
First you have to determine of what you are trying to validate. The carot (^) symbol can mean two things. If its after the opening boundry, it means from the beginning of the string. If its on the right side of a square bracket ([), it means a negated characture class meaning that it will allow all chars except those defined within the class.

A really good tutorial site: http://www.regular-expressions.info/tutorial.html
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-02-2007, 11:20 PM Re: preg_match and ilegal chars at start and end of string
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
I am no expert on PHP regular expressions. Are the comments on the php.net site for preg_match helpful?

http://us3.php.net/preg_match
joder is offline
Reply With Quote
View Public Profile
 
Old 11-02-2007, 11:28 PM Re: preg_match and ilegal chars at start and end of string
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by joder View Post
I am no expert on PHP regular expressions. Are the comments on the php.net site for preg_match helpful?

http://us3.php.net/preg_match
The comments seen there are good for about any regular expression chore you may have, its just written in conjunction with the PHP expression functions.

Regular Expressions is a language syntax that stands alone and uses an engine to parse them seperate to what other language you are using them in. Regex patterns can be used within almost every other programming and scripting environment that is used now.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to preg_match and ilegal chars at start and end of string
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21411 seconds with 12 queries