douxiaomang5640 2013-09-10 15:20
浏览 76
已采纳

Preg_match_all():未知的修饰符'w'

I'm doing parsing some data from HTML codes using preg_match_all() function. in order to make it easier, I use regex tool to do it. so, my pattern is like:

<td class="(weekday|weekend) reservation (primary|alternate) fixwidth calday fixwidth " >(.*?)</td>

when I use it in regex tool I got the result. but when I put into preg_match_all() function, I did not get the result. I've tried running it on online PHP function tester (functions-online.com/preg_match_all.html), the pattern give null result with the message unknown modifier 'w'.

sorry.., this is how I call use preg_match_all function:

preg_match_all('|<td class="(weekday|weekend) reservation (primary|alternate) fixwidth calday fixwidth " >(.*?)</td>|', $v, $matches3, PREG_PATTERN_ORDER);

what makes it has different result? and how to get result using preg_match_all() with that pattern?

I hope somebody help me. Thanks before.

  • 写回答

2条回答 默认 最新

  • dongsou4301 2013-09-10 15:23
    关注

    preg_match_all('/<td class="(weekday|weekend) reservation (primary|alternate) fixwidth calday fixwidth " >(.*?)<\/td>/', $stringToSearch, $results)

    First, you have to use delimiters, eg. / to wrap regexp.

    Second, if you use / as delimiter, you have to escape every occurence of it in provided regexp.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!