
I have a text string like "On River Thames in eastern London" and i want to replace space between two capital words with underscore so that "River Thames" becomes as "River_Thames" for this i am using the following pattern: Pattern p = Pattern.compile("\p{Lu}\p{L}+(\s+\p{Lu}\p{L}+)+");
The problem with this pattern is that it also replaces the space between "On River" to "OnRiver" and after using the complete pattern on input string it becomes "OnRiver_Thames in eastern London".
I want the pattern not to recognize the "On" word so i get output like "On River_Thames in eastern London". to achieve this i am using following pattern but it doesn't seems to work. Pattern p = Pattern.compile("(^On&&\s)+\p{Lu}\p{L}+(\s+\p{Lu}\p{L}+)+");
can someone help me in solving this?
Thanks a lot in Advance...
Regards YJ