当前位置: 动力学知识库 > 问答 > 编程问答 >

regex - Description box check in a form.. PHP

问题描述:

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:]]*$/";
分享给朋友:
您可能感兴趣的文章:
随机阅读: