Reputation: 1601
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 = ", "");
Upvotes: 0
Views: 477
Reputation: 63688
String file_name = newLine3.replaceAll("name\\s+=\\s+", "");
Upvotes: 0
Reputation: 32949
How about:
String input = "name = wlr";
String file_name = newLine3.substring(input.indexof("=") + 1).trim();
Regex seems like overkill for this issue.
Upvotes: 1
Reputation: 328598
String newLine3 = "name = wlr";
String fileName = newLine3.replaceAll("name = ", ""); //fileName = "wlr"
Upvotes: 1