I am interested in regex for finding the following pattern.
I or E for the 1st letter, N or S 2nd, F or T 3rd, and J or P 4th.
This would identify ISTJ, ESTP,ENTP but not EJPT.
Thanks
应该很简单,使用Character Sets:[IE][NS][FT][JP]
对于整个单词:\b[IE][NS][FT][JP]\b
对于整个输入:^[IE][NS][FT][JP]$
工作示例:http ://rubular.com/r/6VCwduNiTX
示例 PHP 代码:http: //ideone.com/XgbFWY
$ptn = "/[IE][NS][FT][JP]/"; // use "/[IE][NS][FT][JP]/i" to ignore case
$str = "ISTJ, ESTP,ENTP but not EJPT";
preg_match_all($ptn, $str, $matches);