com.lostjs.wx4j.utils.WxCodeParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wx4j Show documentation
Show all versions of wx4j Show documentation
A wechat api library through web wechat protocol.
package com.lostjs.wx4j.utils;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by pw on 02/10/2016.
*/
public class WxCodeParser {
public static Optional parse(CharSequence content) {
Pattern pattern = Pattern.compile("window\\.code=(\\d+);");
Matcher matcher = pattern.matcher(content);
if (!matcher.find()) {
return Optional.empty();
}
return Optional.of(Integer.valueOf(matcher.group(1)));
}
}