PHP 正则表达式 - 删除之后的字符
我有类似的 PHP 字符串
$str1 = "hello ... this is the rest of the line"
,或者
$str1 = "ASDFDF ... this is also the rest of the line";
我正在尝试纠正一个正则表达式语句,该语句将在字符串中出现“...”后提取文本。我无法可靠地做到这一点......
所以在上述情况下,我想......
$extract = "这是该行的其余部分";
...你明白了。
I have PHP strings like
$str1 = "hello ... this is the rest of the line"
or
$str1 = "ASDFDF ... this is also the rest of the line";
I am trying to right a regex statement that will extract the text after "..." appears in the string. I am not able to do this reliably..
so in the above cases, i want to...
$extract = "this is the rest of the line";
... you get the point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么使用正则表达式?只需分解字符串并选取结果中的第二个元素:
这基本上是相同的事情,并且正则表达式并不更快。
Why use regex? Just explode the string and pick up the second element in the result:
It's basically the same thing, and the regex for this is no faster.
有多种方法可以做到这一点。
使用 strpos 和 substr:
或使用explode:
There are multiple ways to do it.
Using strpos and substr:
Or using explode:
在
...
爆炸
它是一个很棒的功能:)
explode
it at...
it's a great function :)