php正则表达式怎的去掉换行符rn
php正则表达式怎样去掉换行符\r\n
现在有这么一段字符串:
abcxyz
qwerty
[abc]aaaaaaaa
bbbbbbbbb
ccccccccc[/abc]
poiuyt
lkjhgf
[abc]
dddddd
eeeeeee
ffff[/abc]
poiuy
asdfg
我希望用个正则表达式,把[abc]和[/abc]之间的换行符(也就是\r\n)给替换掉。但是[abc]和[/abc]之外的字符串的换行符保留不变。
上面的是个例子,有可能是这种情况[abc]xxxx[/abc][abc]......,也就是前一个[/abc]和后一个[abc]紧挨着。
如果能兼容linux和windows(换行符好像不一样),就更完美了。
弄了一晚上,请教了群友,仍然没有解决,只好来麻烦大家了。
------解决方案--------------------
如果没有嵌套:
preg_replace_callback( '~\[abc\](.*?)\[/abc\]~msi',
function($matches){
return str_replace(array("\r","\n"),'',$matches[0]);
},
$text);
------解决方案--------------------
- PHP code
$s =<font color="#e78608">------解决方案--------------------</font><br>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is a commonly used relational database management system that provides a variety of functions to process and operate data. Among them, the REPLACE function is used to replace the specified part of the string. In this article, we will introduce how to use the REPLACE function for string replacement in MySQL and demonstrate its usage through code examples. First, let’s take a look at the syntax of the REPLACE function: REPLACE(str,search_str,replace_str).

What are the string search and replace techniques in Python? (Specific code example) In Python, strings are a common data type, and we often encounter string search and replace operations in daily programming. This article will introduce some common string search and replacement techniques, accompanied by specific code examples. To find a specific substring in a string, you can use the find() method or index() method of the string. The find() method returns the index of the first occurrence of the substring in the string.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What coin is ABC? In the field of digital currency, ABC token is a ubiquitous digital asset with unique characteristics and wide applications. This kind of token is usually issued by a project or network and distributed through ICO or other means. ABC tokens usually have specific functions and uses and can play a role in a specific platform or ecosystem. Functions and uses of ABC tokens The functions and uses of ABC tokens vary from project to project, depending on the issuer’s settings and goals. Some ABC tokens are designed to be used for payments within a specific ecosystem and grant holders specific rights or permissions. Other ABC tokens may be used to incentivize users to participate in platform activities, such as providing content, sharing data, or participating in governance decisions. Such a token could be considered an incentive

In Java, use the replace() method of the StringBuilder class to replace part of the content in a string. In Java programming, strings are a very important data type, and strings often need to be processed and manipulated. And sometimes we need to replace part of the string to meet our needs. In Java, you can use the replace() method of the StringBuilder class to implement string replacement operations. StringBuilder is a

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。

图片消失如何解决先是图片文件上传$file=$_FILES['userfile']; if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

Oprah Winfrey interviewed AI technology leaders and the public in an hour-long ABC broadcast titled AI and the Future of Us. The show was created to help the public better understand the benefits and threats of current and emerging AI. The luminaries
