正则表达式,不包含引号但可以包含转义引号 [英] Regular expression that does not contain quote but can contain escaped quote

查看:560
本文介绍了正则表达式,不包含引号但可以包含转义引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

基本上,我想匹配字符串TucoTuco \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:

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

这篇关于正则表达式,不包含引号但可以包含转义引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆