regex - How to search for a special character in java string? -


i having problem searching special character "(".
got java.util.regex.patternsyntaxexception exception has occurred.
might have "(" being treated special character. not pattern expression. can me search escape character?

   // need split string @ "("     string mystring = "room temperature (c)";    string splitlist[] = mystring.split ("(");   // got exception      //  tried got compile error               string splitlist[] = mystring.split ("\(");   

the reason got exception first time because split() takes regular expression argument, , ( has special meaning there, suggest. avoid this, need escape using \, tried.

what missed, need escape backslashes \ in java, meaning need total of two:

string splitlist[] = mystring.split ("\\(");   

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -