Created
March 15, 2017 10:58
-
-
Save du5rte/08504a218e3ad7c18a93ecdc26f56b91 to your computer and use it in GitHub Desktop.
Regex JWT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authorization = "Bearer abcefghijklmnopqrstu.vwxyzABCDEFGHIJKLMNOPQ.RSTUVWXYZ0123456789" | |
// (?:__) no selection group | |
// (__)? optional selection group | |
// (__) selection group | |
// searchers for digits seperated by three dots xx.xx.xx with an optional "Bearer " | |
// retrieve only the jwt (without Bearer) | |
const jwt = authorization.match(/(?:Bearer\s+)?(\w+\.\w+\.\w+)/)[1] // "abcef..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment