Originally posted by vivek ja: How do i find the regex for this particular string. I found the Class Pattern in Sun's site that lists the regex
But when I replace space with \s I am getting a compilation error. It would be really helpful if you can you show me an example how to convert a string to regex?
This is one of the reasons that I don't like the Java regex library. You have to deal with *both* the regex library and Java. "\" has special meaning in a Java string to the compiler, so to get a "\" for the regex string, you need another "\".
Joined: Feb 24, 2005
I got it finally! The final regex looks like this \\<\\?xml\\sversion\\s=\\s'1.0'\\?\\>