Extract Value form JSON Payload using regular expression

Viewed 125

I have below payload

{
   "has_error":false,
   "error_info":{
      
   },
   "count":[
      372684,
      200565
   ],
   "total_count":3095459
}

Need to fetch only the second value in count that is 200565.

Tried with below regular expression \[([^\]]+)\] but it is fetching both the values from count.

Tried JSON path extracter and in that $.count[*], it is also fetching both the values. How can i just fetch the second value ?

1 Answers

Use

\[[^\]]*\b(\d+)\s*\]

See proof.

EXPLANATION

--------------------------------------------------------------------------------
  \[                       '['
--------------------------------------------------------------------------------
  [^\]]*                   any character except: '\]' (0 or more
                           times (matching the most amount possible))
--------------------------------------------------------------------------------
  \b                       the boundary between a word char (\w) and
                           something that is not a word char
--------------------------------------------------------------------------------
  (                        group and capture to \1:
--------------------------------------------------------------------------------
    \d+                      digits (0-9) (1 or more times (matching
                             the most amount possible))
--------------------------------------------------------------------------------
  )                        end of \1
--------------------------------------------------------------------------------
  \s*                      whitespace (\n, \r, \t, \f, and " ") (0 or
                           more times (matching the most amount
                           possible))
--------------------------------------------------------------------------------
  \]                       ']'
Related