Here is some sample input:
<210> DW_AT_name : (indirect string, offset: 0x55): double
DW_AT_name : (indirect string, offset:
You need no regex for this:
String yourString = "<210> DW_AT_name : (indirect string, offset: 0x55): double";
String result;
if (yourString.contains("DW_AT_name")) {
int lastIndex = yourString.lastIndexOf(":");
result = yourString.substring(lastIndex + 1).trim();
} else {
result = "ERROR"; // or handle this however you want
}
System.out.println(result);
Simply find the last :
and take everything after that. Then trim it to remove leading and trailing whitespace.
I edited my question, it needs to also check for DW_AT_name. String split wont [sic] do that.
Just use contains
, then. (edited answer)