Returns a regular expression online ., there are some strings. BS0001/BK0003, BK00006, or BK00006/BBM0009/DDK0003 if a slash exists, the content before the slash is returned. the preceding three results are returned. BS0001, BK00006, and BK00006 are implemented by finding a positive expression. PHPcode $ s online calculates a positive expression.
, There are some strings.
BS0001/BK0003, BK00006, or BK00006/BBM0009/DDK0003
If a slash exists, the content before the slash is returned.
The preceding three results are returned.
BS0001, BK00006, BK00006
Find a regular expression to implement
------ Solution --------------------
PHP code
$ S = 'bs0001/BK0003, or BK00006, or BK00006/BBM0009/DDK0003 '; preg_match_all (' # ([^/\ s] + ?) /# S ', $ s, $ m); print_r ($ m [1]); /* Array ([0] => BS0001 [1] => BK00006 [2] => BBM0009 )*/
------ Solution --------------------
PHP code
$ Str = "BS0001/BK0003, BK00006, or BK00006/BBM0009/DDK0003"; echo preg_replace ("/.*? \ B ([\ w] {6,}) [\ w \/] */I "," \ 1, ", $ str); // BS0001, BK00006, BK00006,