Preg_split问题 [英] Preg_split question

查看:85
本文介绍了Preg_split问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的正则表达式有问题。


我想在字符管道上拆分字符串使用preg_split php函数。


字符串是:


" foo | bar |''hello | world \''abc \\''def''| bye"


拆分结果必须在数组中:


foo



你好| world''abc''def

再见



任何人都有想法?

谢谢!!

再见

解决方案

你正在使用的表达式是什么?

@ Markus


i使用这样的preg_split函数:

展开 | 选择 | Wrap | 行号


嗯,你的分隔符字符串只是''|'',即管道字符?如果是这样,explode()会更适合它。

展开 | 选择 | Wrap | 行号


Hi,

i have a problem with a regular expression.

i want to split a string on character pipe | with preg_split php function.

The string is :

"foo|bar|''hello|world\''abc\''def''|bye"

Result of split must be in an array :

foo
bar
hello|world''abc''def
bye


Anyone have an idea ?
Thank you !!
bye

解决方案

What is the expression you''re using?


@Markus
i use preg_split function like this :

Expand|Select|Wrap|Line Numbers


Hmm, the delimiter of your string is simply ''|'', that is, a pipe character? If so, explode() would be much better suited to it.

Expand|Select|Wrap|Line Numbers


这篇关于Preg_split问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆