class Ideone {
private static final String PATTERN
= "<(\\w+).*?>(.*?)</(\\1)>";
private static final String REPLACEMENT
= "<$1>$2</$1>";
String text
= "<img url='blah'>text</img>"; System.
out.
println(text.
replaceAll(PATTERN, REPLACEMENT
)); }
}
Y2xhc3MgSWRlb25lIHsKCQoJcHJpdmF0ZSBzdGF0aWMgZmluYWwgU3RyaW5nIFBBVFRFUk4gPSAiPChcXHcrKS4qPz4oLio/KTwvKFxcMSk+IjsKCQoJcHJpdmF0ZSBzdGF0aWMgZmluYWwgU3RyaW5nICBSRVBMQUNFTUVOVCA9ICI8JDE+JDI8LyQxPiI7CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgRXhjZXB0aW9uIHsKCQlTdHJpbmcgdGV4dCA9ICI8aW1nIHVybD0nYmxhaCc+dGV4dDwvaW1nPiI7CgkJU3lzdGVtLm91dC5wcmludGxuKHRleHQucmVwbGFjZUFsbChQQVRURVJOLCBSRVBMQUNFTUVOVCkpOwoJfQp9