我有以下类型的字段:
public static final String "some text1", "Test";
public static final String "some text2", "test222";
public static final String "some text3", "someothervalue";
我想让它像这样:
public static final String "some text1";
public static final String "some text2";
public static final String "some text3";
我使用这样的正则表达式:,([^=]*)
但它用分号匹配第一行和字符串的其余部分
最佳答案
只需使用这个: (?=,)(.*\n?)(?=;)
即可找到以 (?=,)
开头并以 (?=,)
结尾的字符(?=;)
并将其替换为空字符串。
关于java - 在 Intellij IDEA 中编写替换正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18542200/