终解
/(\d{1,5}\s[^\d].{5,20}(dr|drive)(\.|\s|\,))/i原始问题
Regex
/([0-9]{1,5}.{5,20}(dr|drive)(\.|\s|\,))/i模式
PO Box 66 23 Britton Drive Bloomfield CT 06002这辆公寓楼正在返回“布里顿大道66号23号”。我要回布里顿大道23号。我试过以下Regex的变体:
/(([0-9]{1,5}.{5,20})?(dr|drive)(\.|\s|\,))/i - adding a new capturing group and making it uncreedy
/([0-9]{1,5}.{5,20}?(dr|drive)(\.|\s|\,))/i - making the length of in between characters ungreedy
/([0-9]{1,5}.{5,20}(dr|drive)(\.|\s|\,))/Ui - adding ungreedy modifier更多不起作用的模式
PO Box 156 430 S Wheeling Dr. Wheeling, IL 60090可以工作的模式
1195 Columbia Dr PO Box 1256 Longview, WA 98632
3400 SW Washington drive PO Box 1349 Peoria, IL 61654发布于 2014-02-01 01:47:23
^[^\d]+\d{2} (\d{2} [^ ]+ [^ ]+)

很明显,我需要更多的模式才能让这个模式适用于所有情况
当前 RegEx的小修复程序
(\d{1,5} [^\d]{5,20}(dr|drive)(\.|\s|\,))https://stackoverflow.com/questions/21493106
复制相似问题