Do JSON regex excluding element

Asked

Viewed 50 times

0

I have the Json below and need to pick up only the return token:

{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb3JtYVBhZ2FtZW50byI6IkJPTEVUTyIsInRlbGVmb2jashdkjhqwkjhekj12hh12h3jkh12j3hkj1hjk3hjkh12j3h1jk2h3jk1h2jk3h1k2jh3jk1h2kjh3k1j2h3kj1h2jk3hkj12h3jk1h2jk3h12kj3hjk12h3jk1h2jkh3kj12h3jk1h2kj3h12jk3hjk12h3jk1h2kj3h21jkh3jk12hrefhasdasuo3242376315268356172dW50IjoiTkVUQVBQIiwiYWRkcmVzc0lkIjpudWxsLCJjb2RpZ29OZXQiOiIwMDMzNDk0MjYzMzAiLCJwZXJmaWxDbGllbnRlIjoyMjgsImNwZiI6IjAzNDM3MDgyMDAwMTI0IiwidGlwb0NvbnRyYXRvIjoxLCJjdXN0b21lck5ldFVubyI6ZmFsc2UsImV4cCI6MTU1ODcxODAyMiwiZGF0YUNhZGFzdHJvIjoxNDM4MTM4ODAwMDAwLCJlbWFpbCI6ImRvdWdsYXMuanVuaW9yQHF1YWxpdHkuY29tLmJyIiwic2VnbWVudG9DbGllbnRlIjoiUE1FIiwic3RhdHVzQ29udHJhdG8iOiIyMCIsInRpcG9TZWdtZW50b0NsaWVudGUiOiI2IiwiY2xpZW50SWQiOm51bGwsImNvbnRyYXRvIjoiMzQ5NDI2MzMwIiwibm9tZSI6IlRFQ0hOT0xPR1kgU1VQUExZIElORk9STUFUSUNBIENPTUVSQ0lPIEkiLCJzdGF0dXNBZGltcGwiOiJ0cnVlIiwibm9kZSI6IklCSVJCIiwidHZBbmFsb2dpYyI6dHJ1ZSwicGhvbmUiOmZhbHNlLCJicm9hZGJhbmQiOnRydWUsImNvZENpZGFkZU5ldCI6Ijg4NDEyIiwiY29kaWdvSW1vdmVsIjo1MzA0MDg2MDMsInN0YXR1c0NvbnRyYXRvRGVzY3JpY2FvIjoiREVTQ09ORUNUQURPIC0gT1BDQU8iLCJzcnNjYWlkc3RhdHVzIjoyMH0.zV5senq3QxOj3ds5dcbj8xMcaOVG1_ynCFVx2wgKICU"
}

If I apply the regex: ([A-Z_.0-9a-z])\w+ i can recover, but come token along, I can delete token literally?

I’m testing here: https://regexr.com/4el37

  • I can only use regex, I’m doing this in the Zabbix, it only allowed the Regex.

1 answer

2


Since the word "token" has 5 letters, you can indicate in regex to start marrying only if the subject has 6 or more characters.

The regex was like this: ([A-Z_.0-9a-z-]){6,}

And here you can see the regex in action.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.