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条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable