正则表达式找到一行有错误的引号
regex find a line have wrong quotation marks
您好,我需要帮助来查找包含错误引号的行。
1 "many word " "many word" "many word "
2 "many word " " <-Error quotation
3 "many word " "many word " " many word " " many word " " <-Error quotation
4 """ but this quotation not match
5 "\"" this is not match
6 " aasd \" " " <-Error quotation \"
only line 2 3 6 have an error quotation
i need to find a line have an error quotation by regex
https://regex101.com/r/bWBV7A/9
非常感谢
使用
^[^"\n]*(?:"""|"[^\\n"]*(?:\.[^\\n"]*)*"[^"\n]*)*+"
说明
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
[^"\n]* any character except: '"', '\n' (newline)
(0 or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
(?: group, but do not capture (0 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
""" '"""'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
[^\\n"]* any character except: '\', '\n'
(newline), '"' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
(?: group, but do not capture (0 or more
times (matching the most amount
possible)):
--------------------------------------------------------------------------------
\ '\'
--------------------------------------------------------------------------------
. any character except \n
--------------------------------------------------------------------------------
[^\\n"]* any character except: '\', '\n'
(newline), '"' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
)* end of grouping
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
[^"\n]* any character except: '"', '\n'
(newline) (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
)*+ end of grouping (possessive match, no backtracking)
您好,我需要帮助来查找包含错误引号的行。
1 "many word " "many word" "many word "
2 "many word " " <-Error quotation
3 "many word " "many word " " many word " " many word " " <-Error quotation
4 """ but this quotation not match
5 "\"" this is not match
6 " aasd \" " " <-Error quotation \"
only line 2 3 6 have an error quotation
i need to find a line have an error quotation by regex
https://regex101.com/r/bWBV7A/9
非常感谢
使用
^[^"\n]*(?:"""|"[^\\n"]*(?:\.[^\\n"]*)*"[^"\n]*)*+"
说明
--------------------------------------------------------------------------------
^ the beginning of the string
--------------------------------------------------------------------------------
[^"\n]* any character except: '"', '\n' (newline)
(0 or more times (matching the most amount
possible))
--------------------------------------------------------------------------------
(?: group, but do not capture (0 or more times
(matching the most amount possible)):
--------------------------------------------------------------------------------
""" '"""'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
[^\\n"]* any character except: '\', '\n'
(newline), '"' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
(?: group, but do not capture (0 or more
times (matching the most amount
possible)):
--------------------------------------------------------------------------------
\ '\'
--------------------------------------------------------------------------------
. any character except \n
--------------------------------------------------------------------------------
[^\\n"]* any character except: '\', '\n'
(newline), '"' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
)* end of grouping
--------------------------------------------------------------------------------
" '"'
--------------------------------------------------------------------------------
[^"\n]* any character except: '"', '\n'
(newline) (0 or more times (matching the
most amount possible))
--------------------------------------------------------------------------------
)*+ end of grouping (possessive match, no backtracking)