开发者

preg_match_all [200932]

I want to pr开发者_如何学JAVAeg_match [200932] this from a string.

I tryied some pattern but didnt help, any idea?


Your question is very vague but I think you probably forgot to escape the square brackets. They denote a character class in RegEx.

preg_match('/\[200932\]/', $str, $matches);

If you were to use /[200932]/ it would mean "2 or 0 or 9 or 3".

Edit:

To capture numbers between square brackets:

/\[(\d+)\]/

That's

\[    A square bracket
(     Start capturing group
 \d+  A digit, 1 or more times
)     End capturing group
\]     A closing square bracket


not sure if I understand your question right, but here is it anyway:

[\[\]0-9]{8}


You tried: #[([.])]#

Try this: \[([0-9]*)\]

(Without the * the string matches only one digit and you used . which matches on all chars even a,b,c,- or /)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜