-4

I would like to put together regex for validating string which comes in format 'FIXED-AAAA-AAAA-AAAA' where 'FIXED' part is fixed static string and other 3 parts can contain alpha numeric characters a..Z and 0..9.

I need regex pattern for JS and PHP.

4

3 回答 3

4

这将起作用:

var re = /^FIXED(?:-[a-zA-Z0-9]{4}){3}$/;

您也可以使用\w通常几乎等同于[a-zA-Z0-9]但可能包含您可能不想拥有的多个字符(ASCII <> UTF)的字符组。

于 2013-05-27T14:29:37.043 回答
0

正则表达式将是

~FIXED-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}~i

对于 php,JavaScript 几乎是相同的,除了最后的修饰符(the i

于 2013-05-27T14:29:59.123 回答
-1
var my_re = /FIXED(?:-[A-Za-z0-9]+){3}/
于 2013-05-27T14:29:12.697 回答