Find a regular expression online. Solution

Source: Internet
Author: User
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,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.