java - Regx to delete a given pattern in string -


in xml have tags

<string1 : string2>

and many more this.

i need write regular expression delete string end ":" , i.e. here string1 , ":" also. , should inside < >

e.g. input = <string1 : string2>

output = <string2>

this how in php:

<?php  $str = "<string1 : string2>";  $s = preg_replace('~(</?)[^>:]*:\s*~', "$1", $str);  var_dump($s); ?> 

edit in java

string str = "<ns2:senderid xmlns=\"netapp.com/fsocanonical\">netapp</ns2:senderid>"; system.out.println(str.replaceall("(</?)[^>:]*:\\s*", "$1")); 

output

<senderid xmlns="netapp.com/fsocanonical">netapp</senderid> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -