Java Regex matching between curly braces

后端 未结 5 716
说谎
说谎 2020-12-03 03:27

I need to parse a log file and get the times and associated function call string This is stored in the log file as so: {\"time\" : \"2012-09-24T03:08:50\", \"message\" : \"C

5条回答
  •  时光取名叫无心
    2020-12-03 04:05

    {} in regexp have special meaning, so they need to be escaped.

    Usually escaping is achieved by preceeding the character to be escaped with a backslash. In a character class defined with square brackets, you shouldn't need to do this

    So something like

    Pattern.compile("\{[^{}]*\}");
    

    Could be nearer to what you want to do

提交回复
热议问题