Home >Backend Development >PHP Tutorial > 请教PHP用正则表达式字符串,只想保留第一个该怎么做

请教PHP用正则表达式字符串,只想保留第一个该怎么做

WBOY
WBOYOriginal
2016-06-13 12:39:311203browse

请问PHP用正则表达式字符串,只想保留第一个该如何做?
PHP
比如说这个字符串有很多个asd,有连续几个的,也有只是一个的,

但是我想只保留第一个asd,后面的asd全部删掉,该怎么做?

(在不影响其他字符的基础上)


ssssssssgsdfasdasdasdasdjlkjhkjhalkasdasdjsdkajshdasdaklsjdasdhkjashgdaklsh

想要的结果:



ssssssssgsdfasdjlkjhkjhalkjsdkajshdaklsjdhkjashgdaklsh

求高手给点提示

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article: 新人求教解决方案 Next article: php static解决思路