正则表达式,不包含引号但可以包含转义引号

编程入门 行业动态 更新时间:2024-10-28 14:29:44
本文介绍了正则表达式,不包含引号但可以包含转义引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一个正则表达式来匹配一个字符串,该字符串可以包含除单引号之外的任何内容,但如果引号被转义,则应匹配。

I am looking for a regular expression to match a string that can contain anything except single quotes, but if the quotes are escaped, it should be matched.

基本上,我想匹配字符串Tuco和Tuco \ABC但不是Tuco;

Essentially, i want to match the String "Tuco" and "Tuco\"ABC" but not "Tuco"";

看起来以下内容与报价不符,但未能与报价匹配。

It looks like the following doesnot match the quotes but fails to match the quote.

"^((?!\").)*$"

什么是正确的正则表达式。

What would be the right regex.

谢谢

基本上我正在寻找任何有效的双引号字符串,如果有任何可能的转义字符..

Essentially i am looking for any valid double quoted string, with possible escape characters if any..

推荐答案

似乎你正在寻找对于带有可能转义的双引号字符串的表达式:

Seems that you are looking for an expression for a double quoted string with possible escapes:

"(?:[^"\\]+|\\.)*"

更多推荐

正则表达式,不包含引号但可以包含转义引号

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

发布评论

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

>www.elefans.com

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