正则表达式不适用于 preg_match_all

发布于 2024-12-26 01:21:38 字数 4542 浏览 1 评论 0原文

我有这个数据:

49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|CABELAS|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|HARLEY-DAVIDSON EDITION|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|KING RANCH|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|CABELAS|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|HARLEY-DAVIDSON EDITION|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|KING RANCH|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed

我使用 RegExr 编写了这个正则表达式。如果该行匹配,它会捕获第 5 列(由 | 分隔):

.*\|.*\|2010\|ford\|(.*)\|.*\|.*\|.*\|.*\|.*\|.*

当我对其运行 preg_match_all 时,出现以下错误:

preg_match_all() [<a href='function.preg-match-all'>function.preg-match-all</a>]: Unknown modifier '*'

I have this data:

49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|CABELAS|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|HARLEY-DAVIDSON EDITION|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|KING RANCH|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-250 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|CABELAS|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|FX4|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|HARLEY-DAVIDSON EDITION|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|KING RANCH|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|LARIAT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|XL|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2008|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2009|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed
49780|Truck|2010|FORD|F-350 SUPER DUTY PICKUP|XLT|6.4L DIESEL V8|||Crew Cab w/81.8 in./6 ft. 9.8 in. Bed|Extended Cab w/81.8 in./6 ft. 9.8 in. Bed

I wrote this regular expression using RegExr. It capture the 5th column (delimited by |) if the row is a match:

.*\|.*\|2010\|ford\|(.*)\|.*\|.*\|.*\|.*\|.*\|.*

When I run a preg_match_all on it, I get this error:

preg_match_all() [<a href='function.preg-match-all'>function.preg-match-all</a>]: Unknown modifier '*'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱人配狗天长地久 2025-01-02 01:21:38

确保您使用 分隔符,看起来您想要一个不区分大小写 也匹配:

$matches = array();
preg_match_all('/.*\|.*\|2010\|ford\|(.*)\|.*\|.*\|.*\|.*\|.*\|.*/i', $subject, $matches);

Make sure you use delimiters, and it looks like you want a case insensitive match as well:

$matches = array();
preg_match_all('/.*\|.*\|2010\|ford\|(.*)\|.*\|.*\|.*\|.*\|.*\|.*/i', $subject, $matches);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文