Created
August 8, 2018 01:25
-
-
Save vicly/522d939aebb541ac0ea2059844e118ca to your computer and use it in GitHub Desktop.
[JWT Regex] #Java #Regex
This file contains hidden or 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
private static final Charset UTF_8 = Charset.forName("UTF-8"); | |
private static final Pattern JWT_PATTERN = Pattern.compile("^([a-zA-Z0-9\\-_]+=*)\\.([a-zA-Z0-9\\-_]+=*)\\.([a-zA-Z0-9\\-_]+=*)$"); | |
Matcher matcher = JWT_PATTERN.matcher(jwt); | |
if (matcher.matches()) | |
{ | |
String header = matcher.group(1); | |
String body = matcher.group(2); | |
String signature = matcher.group(3); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment