regex - regExp matching using older JAVA API -
i m trying replace " \" in string. using
java.util.regex.pattern.compile("\\\"").matcher(mystring).replaceall("\\\\\"")
it works fine development machine m using newer version of java. on test machine throws noclassdeffounerror .the test machine closely resemble production environment has older version of java. not sure version is.
i tried with,
mystring.replaceall("\\\"","\\\\\"");
it throws nosuchmethod exception. same problem with
mystring.matches()
can me out ways work regular expression in older java versions?
thanks in advance..
from symptoms in question, running on jvm older version 1.4, when java.util.regex
package introduced. think try push them upgrade system, since version 1.4 first released 11 years ago in 2002.
for now, can work around string.indexof
, stringbuffer
1. not pretty, sufficient fixed string searching , replacement2.
if insist on regex, jregex library worth trying. site claims works on version of java, , regex features supports quite rich.
footnote
1 stringbuilder
available java 1.5
2 string.replace(charsequence target, charsequence replacement)
, replace fixed string fixed string, available java 1.5.