I'm trying to apply multiple regex on a string. I'm not able to get a good understanding on something of this matter.
I have multiple strings which would under go this replacement:
String csvFile = "/Users/john/Documents/chartFolder/chart_test_1.csv"
String chartTitle = csvFile.replaceAll("_", " ");
chartTitle = chartTitle.replaceAll(".*/", "");
chartTitle = chartTitle.replaceAll("\\..*", "");
I'd like the output to be -
chart test 1
which I achieve, but I feel is not good coding due to the multiple lines of coding.
If someone could please explain if it can be done in 1 line and how they come up with the solution, without just posting the solution that would be great.