本文整理了Java中javax.annotation.RegEx
类的一些代码示例,展示了RegEx
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RegEx
类的具体详情如下:
包路径:javax.annotation.RegEx
类名称:RegEx
暂无
代码示例来源:origin: davidmoten/rxjava2-jdbc
static String camelCaseToUnderscore(String camelCased) {
// guava has best solution for this with CaseFormat class
// but don't want to add dependency just for this method
final @RegEx String regex = "([a-z])([A-Z]+)";
final String replacement = "$1_$2";
return camelCased.replaceAll(regex, replacement);
}
代码示例来源:origin: com.github.davidmoten/rxjava2-jdbc
static String camelCaseToUnderscore(String camelCased) {
// guava has best solution for this with CaseFormat class
// but don't want to add dependency just for this method
final @RegEx String regex = "([a-z])([A-Z]+)";
final String replacement = "$1_$2";
return camelCased.replaceAll(regex, replacement);
}
代码示例来源:origin: opendaylight/yangtools
@RegEx
private static final String PARAM_PATTERN_STR = "\\[\\]$";
private static final Pattern PARAM_PATTERN = Pattern.compile(PARAM_PATTERN_STR);
代码示例来源:origin: com.phloc/phloc-commons-jdk5
@Nonnull
@Nonempty
@RegEx
public String getRegEx ()
{
return m_sRegEx;
}
代码示例来源:origin: com.phloc/phloc-commons-jdk5
/**
* Check if the passed regular expression is invalid.<br>
* Note: this method may be a performance killer, as it calls
* {@link Pattern#compile(String)} each time, which is CPU intensive and has a
* synchronization penalty.
*
* @param sRegEx
* The regular expression to validate. May not be <code>null</code>.
* @return <code>true</code> if the pattern is valid, <code>false</code>
* otherwise.
*/
public static boolean isValidPattern (@Nonnull @RegEx final String sRegEx)
{
try
{
Pattern.compile (sRegEx);
return true;
}
catch (final PatternSyntaxException ex)
{
return false;
}
}
代码示例来源:origin: com.helger/ph-validation
@Nonnull
@Nonempty
@RegEx
public String getRegEx ()
{
return m_sRegEx;
}
代码示例来源:origin: com.phloc/phloc-commons-jdk5
public RegExPattern (@Nonnull @Nonempty @RegEx final String sRegEx) throws IllegalArgumentException
{
// Default: no options
this (sRegEx, 0);
}
代码示例来源:origin: com.helger/ph-validation
public StringRegExValidator (@Nonnull @Nonempty @RegEx final String sRegEx)
{
this (sRegEx, null);
}
代码示例来源:origin: com.phloc/phloc-commons-jdk5
@Nonnull
public static String stringReplacePattern (@Nonnull @RegEx final String sRegEx,
@Nonnegative final int nOptions,
@Nonnull final String sValue,
@Nullable final String sReplacement)
{
// Avoid NPE on invalid replacement parameter
return getMatcher (sRegEx, nOptions, sValue).replaceAll (StringHelper.getNotNull (sReplacement));
}
代码示例来源:origin: com.phloc/phloc-commons-jdk5
/**
* A shortcut helper method to determine whether a string matches a certain
* regular expression or not.
*
* @param sRegEx
* The regular expression to be used. The compiled regular expression
* pattern is cached. May neither be <code>null</code> nor empty.
* @param sValue
* The string value to compare against the regular expression.
* @return <code>true</code> if the string matches the regular expression,
* <code>false</code> otherwise.
*/
public static boolean stringMatchesPattern (@Nonnull @RegEx final String sRegEx, @Nonnull final String sValue)
{
return getMatcher (sRegEx, sValue).matches ();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-generator-util
@RegEx
private static final String NEW_LINE_REGEX = "\\r?\\n";
private static final Pattern NEW_LINE_PATTERN = Pattern.compile(NEW_LINE_REGEX);
@RegEx
private static final String WS_REGEX = "\\s+";
private static final Pattern WS_PATTERN = Pattern.compile(WS_REGEX);
代码示例来源:origin: com.phloc/phloc-commons-jdk5
@Override
@Nullable
@IsLocked (ELockType.WRITE)
protected Pattern getValueToCache (@Nullable @RegEx final RegExPattern aRegEx)
{
return aRegEx == null ? null : aRegEx.getAsPattern ();
}
代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950
@RegEx
private static final String YANG_XPATH_FUNCTIONS_STRING =
"(re-match|deref|derived-from(-or-self)?|enum-value|bit-is-set)([ \t\r\n]*)(\\()";
private static final Pattern YANG_XPATH_FUNCTIONS_PATTERN = Pattern.compile(YANG_XPATH_FUNCTIONS_STRING);
@RegEx
private static final String PATH_ABS_STR = "/[^/].*";
private static final Pattern PATH_ABS = Pattern.compile(PATH_ABS_STR);
代码示例来源:origin: com.phloc/phloc-commons-jdk5
/**
* A shortcut helper method to determine whether a string matches a certain
* regular expression or not.
*
* @param sRegEx
* The regular expression to be used. The compiled regular expression
* pattern is cached. May neither be <code>null</code> nor empty.
* @param nOptions
* The pattern compilations options to be used.
* @param sValue
* The string value to compare against the regular expression.
* @return <code>true</code> if the string matches the regular expression,
* <code>false</code> otherwise.
* @see Pattern#compile(String, int)
*/
public static boolean stringMatchesPattern (@Nonnull @RegEx final String sRegEx,
@Nonnegative final int nOptions,
@Nonnull final String sValue)
{
return getMatcher (sRegEx, nOptions, sValue).matches ();
}
代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding2-generator-util
public final class FormattingUtils {
private static final CharMatcher NEWLINE_OR_TAB = CharMatcher.anyOf("\n\t");
@RegEx
private static final String SPACES_REGEX = " +";
private static final Pattern SPACES_PATTERN = Pattern.compile(SPACES_REGEX);
代码示例来源:origin: com.phloc/phloc-commons-jdk5
/**
* Split the passed text with the given regular expression. If you do not need
* a regular expression, {@link StringHelper#getExploded(String, String)} is a
* faster option.
*
* @param sText
* The text to be split. May be <code>null</code>.
* @param sRegEx
* The regular expression to use for splitting. May neither be
* <code>null</code> nor empty.
* @return An empty array if the text is <code>null</code>, a non-
* <code>null</code> array otherwise. If both text and regular
* expression are <code>null</code> an empty array is returned as well
* since the text parameter is checked first.
*/
@Nonnull
public static String [] getSplitToArray (@Nullable final CharSequence sText, @Nonnull @RegEx final String sRegEx)
{
if (sText == null)
return ArrayHelper.EMPTY_STRING_ARRAY;
return RegExPool.getPattern (sRegEx).split (sText);
}
代码示例来源:origin: org.opendaylight.controller/cds-access-api
@RegEx
private static final String SIMPLE_STRING_REGEX = "^[a-zA-Z0-9-_.*+:=,!~';]+$";
private static final Pattern SIMPLE_STRING_PATTERN = Pattern.compile(SIMPLE_STRING_REGEX);
代码示例来源:origin: com.phloc/phloc-commons-jdk5
public static void checkPatternConsistency (@Nonnull @RegEx final String sRegEx) throws IllegalArgumentException
代码示例来源:origin: com.phloc/phloc-commons-jdk5
/**
* Get the Java Matcher object for the passed pair of regular expression and
* value.
*
* @param sRegEx
* The regular expression to use. May neither be <code>null</code> nor
* empty.
* @param sValue
* The value to create the matcher for. May not be <code>null</code>.
* @return A non-<code>null</code> matcher.
*/
@Nonnull
public static Matcher getMatcher (@Nonnull @RegEx final String sRegEx, @Nonnull final String sValue)
{
ValueEnforcer.notNull (sValue, "Value");
return RegExPool.getPattern (sRegEx).matcher (sValue);
}
代码示例来源:origin: com.phloc/phloc-css-jdk5
@RegEx
private static final String PATTERN_PART_VALUE = "([0-9]+(?:[a-zA-Z]+|%)?|auto)";
@RegEx
private static final String PATTERN_CURRENT_SYNTAX = "^" +
CCSSValue.PREFIX_RECT +
PATTERN_PART_VALUE +
"\\s*\\)$";
@RegEx
private static final String PATTERN_OLD_SYNTAX = "^" +
CCSSValue.PREFIX_RECT +
内容来源于网络,如有侵权,请联系作者删除!