Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex to remove the uri prefix (within tag) only from xml tag
    primarykey
    data
    text
    <p>I need a regular expression to remove the uri prefix(within tag) only from xml tag.</p> <p><strong>Example</strong></p> <p>input:</p> <pre><code>&lt;ns1:fso xlmns:="http://xyz"&gt;&lt;sender&gt;abc&lt;/sender&gt;&lt;/ns1:fso&gt; </code></pre> <p>output:</p> <pre><code>&lt;fso xlmns:="http://xyz"&gt;&lt;sender&gt;abc&lt;/sender&gt;&lt;/fso&gt; </code></pre> <p>Here is my code:</p> <pre><code>import java.util.regex.Matcher; import java.util.regex.Pattern; public final class RegularExpressionTest { private static String REGEX1 = "&lt;\\/?([a-z0-9]+?:).*?&gt;"; private static String INPUT = "&lt;ns1:fso xmlns:ns1='https://www.example.com/fsoCanonical'&gt; &lt;ns2:senderId xmlns='http://www.example.com/fsoCanonical'&gt;abc&lt;/ns2:senderId&gt; &lt;receiverId xmlns='http://www.example.com/fsoCanonical'&gt;testdata&lt;/receiverId&gt; &lt;messageId xmlns='http://www.example.com/fsoCanonical'&gt;4CF4DC05126A0077E10080000A66C871&lt;/messageId&gt; &lt;/ns1:fso&gt; "; private static String REPLACE = ""; public static void main(String[] args) { Pattern p = Pattern.compile(REGEX1); Matcher m = p.matcher(INPUT); // get a matcher object StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, REPLACE); } m.appendTail(sb); System.out.println(sb.toString()); } </code></pre> <p>I am not able to paste the input XML here</p> <blockquote> <p><code>private static String INPUT =</code> </p> </blockquote> <p>is not the correct one as shown in above code. Instead you can take any example of soap message.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload