我有这些行:
This reverts commit c289f6fa1f8642a5caf728ef8ff87afd5718cd99.
This reverts commit c7740a943ec896247ebc5514b6be02710caf3c53. There should
This reverts 518920b764ee9150781e68217181b24d0712748e commit.
我如何使用java上的正则表达式来仅检索数字:
c289f6fa1f8642a5caf728ef8ff87afd5718cd99
c7740a943ec896247ebc5514b6be02710caf3c53
518920b764ee9150781e68217181b24d0712748e
最佳答案
建议:使用JGit .
如果您确实坚持使用正则表达式来执行此操作,那么您可以使用此正则表达式:
\b[a-f0-9]{40}\b
使用:
final Pattern sha1Pattern = Pattern.compile("\\b[a-f0-9]{40}\\b");
final Matcher matcher = sha1Pattern.matcher(yourInput);
if (matcher.find())
// sha1 is accessed via matcher.group()
关于java - 在java上使用正则表达式检索字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17092025/