Solution to the regular expression

Source: Internet
Author: User
Regular expression string: PHPcode & lt; ahref & quot; teamMemberDisplay. php? TTeam & gt; SWDesignandISSScrumTeam2 & lt; a & gt; & lt; br & gt; & lt; ahref & quot; programDisplay. php? Pid positive expression
String:
PHP code
   SW Design and ISS Scrum Team 2
LR RF & HW Modules->LR WCDMA CPRI Baseline->LR CPRI Misc.->SW Dev and Test


Calculate lr rf & HW Modules, lr wcdma cpri Baseline, lr cpri Misc ., SW Dev and Test, and retrieve only the regular expressions of lr rf & HW Modules.
The function I used in php is preg_match.
Thank you !!

------ Solution --------------------
PHP code
$ Str = <
  
   
Lr rf & HW Modules-> lr wcdma cpri Baseline-> lr cpri Misc. -> SW Dev and Test html; // echo $ str; quit (); preg_match_all ('/(? : \ S + |->)] *> (. *) <\/a>/isU ', $ str, $ arr); print_r ($ arr [1]);
   
------ Solution --------------------
$ Text = array ();
$ Html = "SW Design and ISS Scrum Team 2

Lr rf & HW Modules
Lr wcdma cpri Baseline
Lr cpri Misc.
SW Dev and Test ";
Preg_match_all ('| Program \/Domain \/BU \'> (. +) <\/a> | ', $ html, $ matches );
$ Text [0] = $ matches [1] [0];
Preg_match_all ('| Technical Domain \'> (. +) <\/a> | ', $ html, $ matches );
$ Text [1] = $ matches [1] [0];
Preg_match_all ('| Project \'> (. +) <\/a> | ', $ html, $ matches );
$ Text [2] = $ matches [1] [0];
Preg_match_all ('| title = \ 'Team \'> (. +) <\/a> | ', $ html, $ matches );
$ Text [3] = $ matches [1] [1];
Print_r ($ text );
------ Solution --------------------
(? : Expression) the non-capturing group matches the Expression of the subexpression and saves the matching content to the final configuration result of the entire Expression. However, the matching content of the Expression is not separately saved in the same group.

| Or

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.