I'm wanting to (in Java) find any substrings in a string which start with say aba
and end in say aca
, where there is one or more non-whitespace chars between them.
For example" blingblangabablahacablingblang
would find the substring abablahaca
.
Then I want to replace each of those substrings, modifying the start to just b
and the end to ca
, but leaving the internal blah
as it was.
For example" blingblangabablahacablingblang
would be changed to blingblangbblahcablingblang
.
Is there some way I can do this using String.replaceAll() ? There will be many instances within the original string to change.
Thanks for your help.