Did you take a look at the Capturing Groups Tutorial? The second matched group will contain "cancer" or "something". If all strings you want to find end with "lung", you can simply select the second matched group, and add "lung" to it, like so:
Java Code:
Pattern p = Pattern.compile("(([a-zA-Z]+)(?:\sof)?\s(?=lung))");
Matcher m = Pattern.matcher(
"lung cancer of lung is called as something of lung ");
System.out.println(m.group(1) + " lung"); // it might be 2, depending on how Java numbers the groups
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks