In Java programming, how do we check whether the following text contains a piece of information encoded in an <ns1:Elmt> XML element?
Check the following websites and you'll learn how regular expression can ease our programming problems!
Wikipedia : Regular Expression
java.util.regex.Pattern (Java 2 Platform SE 5.0)
Regular-Expressions.info Tutorial
Keywords: java, regular-expressions
An answer: Use the string.matches() method and the following regular expression
This is a preamble #@&%)#*#)$
<ns1:Elmt ns1="uri:ns1" ns2="uri:ns2">
<ns1:SubElmt attr1="value_1">
<ns2:elmt>value_2</ns2:elmt>
</ns1:SubElmt>
</ns1:Elmt>
Here is a little bit more text
3254832 3249028 ~#)*@()(84)_$-
[\s\S]*<ns1:Elmt[\s\S]*</ns1:Elmt>[\s\S]*
Check the following websites and you'll learn how regular expression can ease our programming problems!
Wikipedia : Regular Expression
java.util.regex.Pattern (Java 2 Platform SE 5.0)
Regular-Expressions.info Tutorial
Keywords: java, regular-expressions
Comments