dream0776
2009-06-10 04:52 阅读 57
已采纳

在PHP中的Posix / Perl正则表达式

I have the simple regular expression:

\{[0-9]*\}

which works fine with PHP's ereg_ functions (Posix compatible), but I need to use the preg_match_all function, which doesn't have an ereg_ equivalent. My expression above doesn't seem to work with preg_ (perl compatible) functions. How can I go about "converting" it to be perl compatible?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongta1824 dongta1824 2009-06-10 04:56

    If im reading your regex correctly then just do this:

    preg_match_all('/\{\d*?\}/'...);
    

    '/\{\d*?\}/' will match an integer of any length.

    点赞 评论 复制链接分享

相关推荐