问题
I would like to know if anyone knows the regex command to remove the following
name =
from the following
name = wlr
leaving only
wlr
these details are taken from a txt file but the name = part can appear multiple times
So I was thinking something like this would work but it doesn't work properly
String file_name = newLine3.replaceAll("name = ", "");
回答1:
String file_name = newLine3.replaceAll("name\\s+=\\s+", "");
回答2:
String newLine3 = "name = wlr";
String fileName = newLine3.replaceAll("name = ", ""); //fileName = "wlr"
回答3:
How about:
String input = "name = wlr";
String file_name = newLine3.substring(input.indexof("=") + 1).trim();
Regex seems like overkill for this issue.
来源:https://stackoverflow.com/questions/10139623/java-replaceallregex-replacement-regex-command