正则表达式删除“= \ r”(Regex to remove “=\r”)

编程入门 行业动态 更新时间:2024-10-26 06:33:44
正则表达式删除“= \ r”(Regex to remove “=\r”)

以下是我拥有的文字:

[ ' "message": "WorldStage Supports Massive 4K Video Mapping at Adobe MAX=\r with Christie Boxer 4K Projectors', ' "message": "Inside Track: Trading Focus on Shares of Adobe Systems In=\r c. (ADBE)' ]

我希望它看起来像:

[ ' "message": "WorldStage Supports Massive 4K Video Mapping at Adobe with Christie Boxer 4K Projectors', ' "message": "Inside Track: Trading Focus on Shares of Adobe Systems Inc. (ADBE)' ]

正则表达式我试过了:

texts[i].replace(/=\\r/g, "")

但它不起作用。 可以在StackOverflow中找到类似的问题。 :(

Here's the text I have:

[ ' "message": "WorldStage Supports Massive 4K Video Mapping at Adobe MAX=\r with Christie Boxer 4K Projectors', ' "message": "Inside Track: Trading Focus on Shares of Adobe Systems In=\r c. (ADBE)' ]

I want it to look like:

[ ' "message": "WorldStage Supports Massive 4K Video Mapping at Adobe with Christie Boxer 4K Projectors', ' "message": "Inside Track: Trading Focus on Shares of Adobe Systems Inc. (ADBE)' ]

Regex I tried:

texts[i].replace(/=\\r/g, "")

But it is not working. Could find similar issues at StackOverflow. :(

最满意答案

您的正则表达式 - /=\\r/g - 匹配a = , \和r所有实例。

您似乎想要删除符号后的所有=和换行符的实例。

使用

.replace(/=[\r\n]+/g, "")

=[\r\n]+匹配a = ,并且[\r\n]+匹配在字符类LF(换行符号\n )和CR(回车符\r )中定义的一个或多个字符。

Your regex - /=\\r/g - matches all instances of a =, \ and r.

You seem to want to remove all instances of = and line breaks after the symbol.

Use

.replace(/=[\r\n]+/g, "")

The =[\r\n]+ matches a =, and [\r\n]+ matches 1 or more characters defined in the character class, LF (newline symbol, \n) and CR (carriage return, \r).

更多推荐

本文发布于:2023-07-26 17:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278875.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正则表达式   Regex   remove

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!