
com.sirolf2009.util.RegexUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of util Show documentation
Show all versions of util Show documentation
A collection of my common utilities
The newest version!
package com.sirolf2009.util;
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@SuppressWarnings("all")
public class RegexUtil {
public static String extract(final String string, final String pattern) {
return RegexUtil.extract(string, Pattern.compile(pattern));
}
public static String extract(final String string, final Pattern pattern) {
final Matcher matcher = pattern.matcher(string);
boolean _find = matcher.find();
if (_find) {
return matcher.group(1);
} else {
String _pattern = pattern.pattern();
String _plus = ((("The string \"" + string) + "\" does not contain the pattern \"") + _pattern);
String _plus_1 = (_plus + "\"");
throw new NoSuchElementException(_plus_1);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy