Menu

How to match string such "C++"

Help
2004-08-03
2004-08-04
  • Nobody/Anonymous

    when i use pattern = new Pattern("C++"),it report wrong ,it regard ++ as specical char ,in fact ,it not a specical char,just a common char,If I want to match all string such as "C++",what should i do??

     
    • Nobody/Anonymous

      Use backslash to escape special chars
      new Pattern("C\\+\\+")
      see more on escaping here:
      http://jregex.sourceforge.net/gstarted.html#appendix-d

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.