开发者

php regex unlimited pattern

开发者 https://www.devze.com 2022-12-28 11:36 出处:网络
I\'m looking to extend the regex below so I can have unlimited number of braces. ((?:{[0-9]:[a-z]+})?)

I'm looking to extend the regex below so I can have unlimited number of braces.

((?:{[0-9]:[a-z]+})?)

So my string can handle {1:foo}{2:bar}{3:more}

Any ideas will 开发者_JAVA技巧be appreciate it!


Which function are you using in PHP for matching the expression? Using preg_match_all should work for you with the follow regex: /\{([0-9]):([a-z]+)\}/

0

精彩评论

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