$string = ' dj%a3%a3999 '; if (Preg_match ('/^[dj]{2} ([(\%23) (\%A3\%A3)]) ((\w) +) $/i ', $string, $result)) {Print_r ($ result);}
No match, there is no good solution.
Reply to discussion (solution)
You'd better talk about your needs, the middle part of it is very messy to see you.
/* Demand is DJ a grouping%a3%a3 or%23 is another grouping 999 is a grouping that gets the corresponding data by $result. such as: */$result [0]= ' DJ '; $result [1]= '%a3%a3 '; $result [2]= ' 999 ';
$s = ' dj%a3%a3999 ';p reg_match ('/([^%]+) ((?:%a3|23) +) (. +)/', $s, $r);p Rint_r ($r);
Array ([0] = dj%a3%a3999 [1] = DJ [2] =%A3%A3 [3] = 999)
Used this:
$string = ' dj%a3%a3999 '; if (Preg_match ('/^ ([dj]{2}) ([%a3]+] (\d{3}) $/i ', $string, $result)) {Print_r ($result);}
Results:
Array ([0] = dj%a3%a3999 [1] = DJ [2] =%A3%A3 [3] = 999)
$s = ' dj%a3%a3999 ';p reg_match ('/([^%]+) ((?:%a3|23) +) (. +)/', $s, $r);p Rint_r ($r);
Array ([0] = dj%a3%a3999 [1] = DJ [2] =%A3%A3 [3] = 999)
If $s = ' dj%23999 ';
Used this:
$string = ' dj%a3%a3999 '; if (Preg_match ('/^ ([dj]{2}) ([%a3]+] (\d{3}) $/i ', $string, $result)) {Print_r ($result);}
[/code]
This string also needs to match: $string = ' dj%23999 ';
$s = ' dj%23999 ';
Preg_match ('/([^%]+) ((?:% (?: a3|23)) +) (. +)/', $s, $r);
Or
Preg_match ('/([^%]+) ((?:%a3|%23) +) (. +)/', $s, $r);
The regular expression Rule description has:
| If there is ambiguity in the operation, it needs to be listed individually or enclosed in parentheses.
Obviously (?:%a3|23)% was incorporated into the A3 so that there was ambiguity
Boss, can you help me explain, I see there are a lot of regular front plus?: I want to know what this means?
(?:...) Same as group (...), but results do not appear in result set
(?:...) Same as group (...), but results do not appear in result set
Boss, can you help me match an address, such as:
Www.sohu.com,www.baidu.com,www.yahoo.com.n
This connects to a maximum of 9 URLs, which can also match sohu.com,baidu.com,yahoo.com.cn
(?! (W)) (\w+ (-\w+) *) (\. (\w+ (-\w+) *)) *