java regex : getting a substring from a string which can vary

后端 未结 5 1646
借酒劲吻你
借酒劲吻你 2021-01-22 19:53

I have a String like - \"Bangalore,India=Karnataka\". From this String I would like to extract only the substring \"Bangalore\". In this case the regex

5条回答
  •  难免孤独
    2021-01-22 20:41

    matcher.matches()
    

    tries to match against the entire input string. Look at the javadoc for java.util.regex.Matcher. You need to use:

    matcher.find()
    

提交回复
热议问题