问题描述:

I am having problems with my regular expression that is not passing through the error..

What is my regular expression supposed to do?

Check the textarea and allow any inputs that contains letters, digits, periods, commas, apostrophes, dashes and spaces only (may contain newlines since this is a multiline textarea)..

This is my regular expression:

preg_match("/^[ ]*[a-zA-Z]+[\s]*[\d\.,'-]*[ ]*$/")

Btw, it may allow leading and trailing blanks... I hope some can help me.

网友答案:

If the data can contain spaces, then you do not need to specify leading trailing blanks.

Try:

$pattern = "/^[-\.,'\s[:alnum:]]*$/";
相关阅读:
Top