How can one or more regular expressions be matched consecutively? When I capture the train fare, I encountered this problem. some train fares only come out of one type, and some may come out of several types. how can I use one expression to continuously match one or more trains? For example, the following are three possible results: "& lt; td & gt; & nbsp; 234 RMB for hard seat & lt; br & nbsp;/& gt; & nbsp; & n how can one or more regular expressions be matched consecutively?
When I capture the train fare, I encountered this problem. some train fares only come out of one type, and some may come out of several types. how can I use one expression to continuously match one or more trains?
For example, the following are three possible results:
"234 yuan for hard seat Hard sleeper 391/407/420 yuan 613/638 yuan for soft sleeper ";
"234 yuan for hard seat Hard sleeper 391/407/420 yuan ";
"234 yuan for hard seat ";
I want to use the following method, but it does not seem to work. I can only get the last fare. why?
Preg_match ('# (\ s + (.*?) ) + # Is ', $ singleShift, $ piaojia); // fare
Thank you!
------ Solution --------------------
$ SingleShift ="234 yuan for hard seat
Hard sleeper 391/407/420 yuan
613/638 yuan for soft sleeper
";
Preg_match_all ('#(? : \ S + (.*)
) + # IsU ', $ singleShift, $ piaojia );
Print_r ($ piaojia [1]);
Array
(
[0] => 234 yuan for a hard seat
[1] => hard sleeper 391/407/420 yuan
[2] => 613/638 yuan for a soft sleeper
)