Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Java 8

"
(?:\"(?:errorType)\"(?:[^:])*):(?:(?:[^\",])*)\"([^\"]*)
"
g

Description

Sample:

Finds errorType key values from a json. Values are returned in capturing group 1 of each match. Both UNKNOWN and UNAUTHENTICATED will be captured.

 {
  "data": null,
  "errors": [
    {
      "message": "Message",
      "extensions": {
        "errorType": "UNKNOWN",
        "error_code": "AUTHENTICATE_USER_FALSE"
      }
    },
    {
      "message": "Message",
      "extensions": {
        "errorType": "UNAUTHENTICATED",
        "error_code": "AUTHENTICATE_USER_FALSE"
      }
    }
  ]
}
Submitted by amansaryal - 2 years ago (Last modified 2 years ago)