简体   繁体   English

正则表达式匹配特定字符串

[英]Regular expression match for specific string

I have a below string to compare in PHP.and i made one regular expression for match the string.But it only match exactly same string so can some one help to get me regular expression to match below conditional string. 我有一个下面的字符串要在PHP中进行比较。我做了一个正则表达式来匹配这个字符串。但是它只匹配完全相同的字符串,所以可以有人帮我让正则表达式匹配下面的条件字符串。

I have used below expression. 我用下面的表达。

[poBox]\s\d{3}

below is my conditional string to match 以下是我要匹配的条件字符串

POBox 123, POBox 1234, P.O.Box 123, P.O.Box 1234, P O Box 123, P O Box 1234, P.O. Box 123, P.O. Box 1234

[poBox] means any one character between p , o , B or x . [poBox]表示poBx之间的任何一个字符。 And \\d{3} will not match the full extent of 1234 . 并且\\d{3}将不匹配1234的整个范围。

P\.?\s?O\.?\s?Box\s\d+

regex101 . regex101

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM