PHP:RegEx检测正常的人类可读字符串?

时间:2015-04-06 16:02:08

标签: php regex string

说我有几个字符串,如:

[0]Hey how are you?
[1]13A315Bdas
[2]d3s315
[3]Billy
[4]daa2315Fasd

如何在PHP中使用正则表达式将数字1,2和4作为无效字符串展开并将0和3保持为有效字符串?

类似于:

LettersNumbersLetters = false;
NumbersLetters = false;
Numbers = true;
Letters = true;

因此,只要String中的Numbers有效,或者String中的字母有效。

1 个答案:

答案 0 :(得分:1)

您可以使用(?<=^\[)[035-9](?=\])正则表达式,如果字符串包含匹配项,则它是有效的。请参阅demo on regex101.com