/    Sign up×
Community /Pin to ProfileBookmark

preg_match RegEx

Hi,

I’m trying to make validation for my form and I have some problems with my RegEx.

I have for example a RexEx to validate the name and firstname.

‘/^[A-ZÉÏÎÈÇ A-Za-z ZÉÏÎÈÇéïîèç]+([ ][A-ZÉÏÎÈÇ][a-zéïîèç]*)?[a-z éïîèç]*[a-zéïîèç]$/’

The problem is that it don’t work when I’m using post values

preg_match(‘/^[A-ZÉÏÎÈÇ A-Za-z ZÉÏÎÈÇéïîèç]+([ ][A-ZÉÏÎÈÇ][a-zéïîèç]*)?[a-z éïîèç]*[a-zéïîèç]$/’, $_POST[‘name’]);

$_POST[‘name’] = ‘Étienne’;

But when I hardcode a value it work

preg_match(‘/^[A-ZÉÏÎÈÇ A-Za-z ZÉÏÎÈÇéïîèç]+([ ][A-ZÉÏÎÈÇ][a-zéïîèç]*)?[a-z éïîèç]*[a-zéïîèç]$/’, ‘Étienne’);

Both ways use the same RegEx why it don’t work with $_POST but it do with hardcoded value. I need to use the $_POST.

Thank you

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 20.2009 — Just a quick thought without analyzing the actual regexp would be to add the "u" modifier for UTF-8 recognition.
Copy linkTweet thisAlerts:
@narolisauthorMay 25.2009 — No still don't work
Copy linkTweet thisAlerts:
@narolisauthorMay 29.2009 — I solved my problem, It was caused by the encoding of my Aptana.

thank to you all
×

Success!

Help @narolis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...