1

If I have the string:

Detroit 10    New Jersey 2 (FINAL)

Is there a way to match Detroit 10 and New Jersey 2 in a single regular expression?

I can't figure out how to do it if the city names are different lengths and some have spaces in the city name.

4

2 に答える 2

0

これを試して:

$str = "Detroit 10    New Jersey 2 (FINAL)";

preg_match_all("/(\w+ )+\d+/", $str, $m);

print_r( $m[0] );// the resulted strings are in this table $m[0]

それが役に立てば幸い

于 2013-02-16T16:42:11.160 に答える
0

数字を使用して都市名の末尾を区切る正規表現を使用できます。

お気に入り:

/([^\d]*\d+)/
于 2013-02-16T04:58:20.097 に答える