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

后端 未结 5 1647
借酒劲吻你
借酒劲吻你 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:32

    Try this regex, This will grab any grouping of characters at the start followed by a comma but not the comma itself.

    ^.*(?=,)

提交回复
热议问题