我尝试使用正则表达式(?<=^(?![ \t]*@).+)(?<![\{\};:)]|//.{0,1024}|^[ \t]+)\R
来:
该正则表达式在Eclipse搜索中有效,但我无法替换匹配,因为Eclipse发现并替换了错误。然后我在Notepad++和TextPad中尝试了它,但他们告诉我正则表达式格式不正确。我尝试在在线regexp验证器中验证正则表达式,并说我正则表达式有错误。
如何构建满足所列要求的正确正则表达式?
has to match the new line.
has to match the new line.
has to match the new line
doesn't have to match the new line;
doesn't have match the new line {
doesn't have to match the new line}
doesn't have to match the new line:
doesn't have to match the new line //because of this
@doesn't have to match the new line
h@s to match the new line-
答案 0 :(得分:0)
您可以尝试使用此正则表达式^[^@]+[ ]*.*[ ]*([^;{}:]+)[ ]*$
它将涵盖除了一个
以外的所有情况不必匹配新行//因为这个