• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RegExHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.helger.commons.regex.RegExHelper的典型用法代码示例。如果您正苦于以下问题:Java RegExHelper类的具体用法?Java RegExHelper怎么用?Java RegExHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RegExHelper类属于com.helger.commons.regex包,在下文中一共展示了RegExHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: _performConsistencyChecks

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
private static void _performConsistencyChecks (@Nonnull final String sValue)
{
  // String contains masked newline? warning only!
  if (sValue.contains ("\\n"))
    s_aLogger.warn ("Passed string contains a masked newline - replace with an inline one:\n" + sValue);

  if (sValue.contains ("{0}"))
  {
    // When formatting is used, 2 single quotes are required!
    if (RegExHelper.stringMatchesPattern ("^'[^'].*", sValue))
      throw new IllegalArgumentException ("The passed string seems to start with unclosed single quotes: " + sValue);
    if (RegExHelper.stringMatchesPattern (".*[^']'[^'].*", sValue))
      throw new IllegalArgumentException ("The passed string seems to contain unclosed single quotes: " + sValue);
  }
  else
  {
    // When no formatting is used, single quotes are required!
    if (RegExHelper.stringMatchesPattern (".*''.*", sValue))
      throw new IllegalArgumentException ("The passed string seems to contain 2 single quotes: " + sValue);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:22,代码来源:AbstractReadOnlyMapBasedMultilingualText.java


示例2: filenameMatchAnyRegEx

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Create a file filter that matches, if it matches one of the provided
 * regular expressions
 *
 * @param aRegExs
 *        The regular expressions to match against. May neither be
 *        <code>null</code> nor empty.
 * @return The created {@link IFileFilter}. Never <code>null</code>.
 * @see #filenameMatchNoRegEx(String...)
 * @see #filenameMatchAny(String...)
 * @see #filenameMatchNone(String...)
 */
@Nonnull
static IFileFilter filenameMatchAnyRegEx (@Nonnull @Nonempty final String... aRegExs)
{
  ValueEnforcer.notEmpty (aRegExs, "RegularExpressions");
  return aFile -> {
    if (aFile != null)
    {
      final String sRealName = FilenameHelper.getSecureFilename (aFile.getName ());
      if (sRealName != null)
        for (final String sRegEx : aRegExs)
          if (RegExHelper.stringMatchesPattern (sRegEx, sRealName))
            return true;
    }
    return false;
  };
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:29,代码来源:IFileFilter.java


示例3: filenameMatchNoRegEx

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Create a file filter that matches, if it matches none of the provided
 * regular expressions
 *
 * @param aRegExs
 *        The regular expressions to match against. May neither be
 *        <code>null</code> nor empty.
 * @return The created {@link IFileFilter}. Never <code>null</code>.
 * @see #filenameMatchAnyRegEx(String...)
 * @see #filenameMatchAny(String...)
 * @see #filenameMatchNone(String...)
 */
@Nonnull
static IFileFilter filenameMatchNoRegEx (@Nonnull @Nonempty final String... aRegExs)
{
  ValueEnforcer.notEmpty (aRegExs, "RegularExpressions");
  return aFile -> {
    if (aFile == null)
      return false;
    final String sRealName = FilenameHelper.getSecureFilename (aFile.getName ());
    if (sRealName == null)
      return false;
    for (final String sRegEx : aRegExs)
      if (RegExHelper.stringMatchesPattern (sRegEx, sRealName))
        return false;
    return true;
  };
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:29,代码来源:IFileFilter.java


示例4: unifyIBAN

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Make an IBAN that can be parsed. It is converted to upper case and all
 * non-alphanumeric characters are removed.
 *
 * @param sIBAN
 *        The IBAN to be unified.
 * @return The unified string or <code>null</code> if this is no IBAN at all.
 */
@Nullable
public static String unifyIBAN (@Nullable final String sIBAN)
{
  if (sIBAN == null)
    return null;

  // to uppercase
  String sRealIBAN = sIBAN.toUpperCase (Locale.US);

  // kick all non-IBAN chars
  sRealIBAN = RegExHelper.stringReplacePattern ("[^0-9A-Z]", sRealIBAN, "");
  if (sRealIBAN.length () < 4)
    return null;

  return sRealIBAN;
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:25,代码来源:IBANManager.java


示例5: isValidISBN10Number

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
public static boolean isValidISBN10Number (@Nullable final String sValue)
{
  if (sValue == null || sValue.length () != 10)
    return false;

  // Value needs to be fully numeric with a trailing 'X'
  if (!RegExHelper.stringMatchesPattern ("^[0-9]+[0-9X]?$", sValue))
    return false;

  // calc checksum
  int nRes = 0;
  for (int i = 0; i < 9; i++)
  {
    final int j = Character.digit (sValue.charAt (i), 10);
    nRes += ((j * (10 - i)) % 11);
  }
  nRes = 11 - (nRes % 11);
  final char cChkSum = (nRes == 10 ? 'X' : Character.forDigit (nRes, 10));
  return cChkSum == sValue.charAt (9);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:21,代码来源:ISBN.java


示例6: isValidISBN13Number

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
public static boolean isValidISBN13Number (@Nullable final String sValue)
{
  if (sValue == null || sValue.length () != 13)
    return false;
  // Value needs to be fully numeric
  if (!RegExHelper.stringMatchesPattern ("^[0-9]+$", sValue))
    return false;

  // calc checksum
  int nRes = 0;
  for (int i = 0; i < 12; i++)
  {
    final int j = Character.digit (sValue.charAt (i), 10);
    final int k = 1 + ((i % 2) * 2);
    nRes += ((j * k) % 10);
  }
  nRes = (10 - (nRes % 10)) % 10;
  return Character.forDigit (nRes, 10) == sValue.charAt (12);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:20,代码来源:ISBN.java


示例7: getBeautifiedLocation

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Convert an "unsexy" location string in the for, of
 * <code>*:xx[namespace-uri()='yy']</code> to something more readable like
 * <code>prefix:xx</code> by using the mapping registered in the
 * {@link SVRLLocationBeautifierRegistry}.
 *
 * @param sLocation
 *        The original location string. May not be <code>null</code>.
 * @return The beautified string. Never <code>null</code>. Might be identical
 *         to the original string if the pattern was not found.
 * @since 5.0.1
 */
@Nonnull
public static String getBeautifiedLocation (@Nonnull final String sLocation)
{
  String sResult = sLocation;
  // Handle namespaces:
  // Search for "*:xx[namespace-uri()='yy']" where xx is the localname and yy
  // is the namespace URI
  final Matcher aMatcher = RegExHelper.getMatcher ("\\Q*:\\E([a-zA-Z0-9_]+)\\Q[namespace-uri()='\\E([^']+)\\Q']\\E",
                                                   sResult);
  while (aMatcher.find ())
  {
    final String sLocalName = aMatcher.group (1);
    final String sNamespaceURI = aMatcher.group (2);

    // Check if there is a known beautifier for this pair of namespace and
    // local name
    final String sBeautified = SVRLLocationBeautifierRegistry.getBeautifiedLocation (sNamespaceURI, sLocalName);
    if (sBeautified != null)
      sResult = StringHelper.replaceAll (sResult, aMatcher.group (), sBeautified);
  }
  return sResult;
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:35,代码来源:SVRLHelper.java


示例8: isValidValue

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Override
@OverridingMethodsMustInvokeSuper
public boolean isValidValue (@Nullable final String sValue)
{
  if (sValue == null)
    return false;

  // Split by whitespaces " a b " results in { "a", "b" }
  final String [] aParts = RegExHelper.getSplitToArray (sValue.trim (), "\\s+");
  if (aParts.length < getMinimumArgumentCount () || aParts.length > getMaximumArgumentCount ())
    return false;

  // Check each value
  for (final String aPart : aParts)
  {
    final String sTrimmedPart = aPart.trim ();
    if (!super.isValidValue (sTrimmedPart) && !CSSColorHelper.isColorValue (sTrimmedPart))
      return false;
  }
  return true;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:22,代码来源:CSSPropertyEnumOrColors.java


示例9: isValidValue

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Override
@OverridingMethodsMustInvokeSuper
public boolean isValidValue (@Nullable final String sValue)
{
  if (super.isValidValue (sValue))
    return true;

  if (sValue == null)
    return false;

  // Split by whitespaces
  final String [] aParts = RegExHelper.getSplitToArray (sValue.trim (), "\\s+");
  if (aParts.length < m_nMinNumbers || aParts.length > m_nMaxNumbers)
    return false;

  // Check if each part is a valid number
  for (final String sPart : aParts)
    if (!CSSNumberHelper.isValueWithUnit (sPart.trim (), m_bWithPercentage))
      return false;
  return true;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:22,代码来源:CSSPropertyNumbers.java


示例10: isValidValue

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Override
@OverridingMethodsMustInvokeSuper
public boolean isValidValue (@Nullable final String sValue)
{
  if (sValue == null)
    return false;

  // Split by whitespaces " a b " results in { "a", "b" }
  final String [] aParts = RegExHelper.getSplitToArray (sValue.trim (), "\\s+");
  if (aParts.length < getMinimumArgumentCount () || aParts.length > getMaximumArgumentCount ())
    return false;

  for (final String sPart : aParts)
    if (!super.isValidValue (sPart.trim ()))
      return false;
  return true;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:18,代码来源:CSSPropertyEnums.java


示例11: isValidValue

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Override
@OverridingMethodsMustInvokeSuper
public boolean isValidValue (@Nullable final String sValue)
{
  if (sValue == null)
    return false;

  // Split by whitespaces " a b " results in { "a", "b" }
  final String [] aParts = RegExHelper.getSplitToArray (sValue.trim (), "\\s+");
  if (aParts.length < m_nMinNumbers || aParts.length > m_nMaxNumbers)
    return false;

  for (final String aPart : aParts)
  {
    final String sTrimmedPart = aPart.trim ();
    if (!super.isValidValue (sTrimmedPart) && !CSSNumberHelper.isValueWithUnit (sTrimmedPart, m_bWithPercentage))
      return false;
  }
  return true;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:21,代码来源:CSSPropertyEnumOrNumbers.java


示例12: isRectValue

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Check if the passed value is CSS rectangle definition or not. It checks
 * both the current syntax (<code>rect(a,b,c,d)</code>) and the old syntax (
 * <code>rect(a b c d)</code>).
 *
 * @param sCSSValue
 *        The value to check. May be <code>null</code>.
 * @return <code>true</code> if the passed value is a rect value,
 *         <code>false</code> if not
 */
public static boolean isRectValue (@Nullable final String sCSSValue)
{
  final String sRealValue = StringHelper.trim (sCSSValue);
  if (StringHelper.hasText (sRealValue))
  {
    // Current syntax: rect(a,b,c,d)
    if (RegExHelper.stringMatchesPattern (PATTERN_CURRENT_SYNTAX, sRealValue))
      return true;

    // Backward compatible syntax: rect(a b c d)
    if (RegExHelper.stringMatchesPattern (PATTERN_OLD_SYNTAX, sRealValue))
      return true;
  }
  return false;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:26,代码来源:CSSRectHelper.java


示例13: getSplitIntoTerms

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Split a user provided query string into the terms relevant for querying
 * using the provided Lucene Analyzer. This will e.g. remove ":" from a word
 * etc.
 *
 * @param aAnalyzerProvider
 *        Analyzer provider. E.g. instance of
 *        {@link com.helger.pd.indexer.lucene.PDLucene}.
 * @param sFieldName
 *        Lucene field name to get split into terms.
 * @param sQueryString
 *        The user provided query string. Must neither be <code>null</code>
 *        nor empty.
 * @return The non-<code>null</code> list of all terms.
 */
@Nonnull
public static ICommonsList <String> getSplitIntoTerms (@Nonnull final ILuceneAnalyzerProvider aAnalyzerProvider,
                                                       @Nonnull @Nonempty final String sFieldName,
                                                       @Nonnull @Nonempty final String sQueryString)
{
  // Use the default analyzer to split the query string into fields
  try (final TokenStream aTokenStream = aAnalyzerProvider.getAnalyzer ().tokenStream (sFieldName, sQueryString))
  {
    final ICommonsList <String> ret = new CommonsArrayList <> ();
    final CharTermAttribute aCharTermAttribute = aTokenStream.addAttribute (CharTermAttribute.class);
    aTokenStream.reset ();
    while (aTokenStream.incrementToken ())
    {
      final String sTerm = aCharTermAttribute.toString ();
      ret.add (sTerm);
    }
    aTokenStream.end ();
    return ret;
  }
  catch (final IOException ex)
  {
    s_aLogger.warn ("Failed to split user query '" + sQueryString + "' into terms. Defaulting to regEx splitting",
                    ex);
    // Fall-back
    return RegExHelper.getSplitToList (sQueryString.trim (), "\\s+");
  }
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:43,代码来源:PDQueryManager.java


示例14: _containsER

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
private static boolean _containsER (final String s, final int c)
{
  if (s.indexOf ("&#" + c + ";") >= 0)
    return true;
  if (s.indexOf ("&#x" + Integer.toString (c, 16) + ";") >= 0)
    return true;
  return RegExHelper.stringMatchesPattern (".+&[a-z]+;.+", s);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:9,代码来源:MainFindMaskedXMLChars.java


示例15: getValidLanguageCode

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Nullable
public static String getValidLanguageCode (@Nullable final String sCode)
{
  if (StringHelper.hasText (sCode) &&
      (RegExHelper.stringMatchesPattern ("[a-zA-Z]{2,8}", sCode) || isSpecialLocaleCode (sCode)))
  {
    return sCode.toLowerCase (CGlobal.LOCALE_FIXED_NUMBER_FORMAT);
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:11,代码来源:LocaleHelper.java


示例16: getValidCountryCode

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Nullable
public static String getValidCountryCode (@Nullable final String sCode)
{
  if (StringHelper.hasText (sCode) && RegExHelper.stringMatchesPattern ("[a-zA-Z]{2}|[0-9]{3}", sCode))
  {
    return sCode.toUpperCase (CGlobal.LOCALE_FIXED_NUMBER_FORMAT);
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:10,代码来源:LocaleHelper.java


示例17: getCleanedLine

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Nullable
@CheckReturnValue
public static String getCleanedLine (@Nullable final String sLine)
{
  String ret = StringHelper.trim (sLine);
  if (StringHelper.hasText (ret))
  {
    // Remove the Skype highlighting :)
    ret = RegExHelper.stringReplacePattern ("begin_of_the_skype_highlighting.+end_of_the_skype_highlighting",
                                            ret,
                                            "");
  }
  return ret;
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:15,代码来源:TelephoneHelper.java


示例18: setDiagnostics

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Set the diagnostics, as an IDREFS value (multiple IDREF values separated by
 * spaces)
 *
 * @param sDiagnostics
 *        The value to be set. May be <code>null</code>.
 */
public void setDiagnostics (@Nullable final String sDiagnostics)
{
  if (StringHelper.hasText (sDiagnostics))
    setDiagnostics (RegExHelper.getSplitToList (sDiagnostics.trim (), "\\s+"));
  else
    m_aDiagnostics = null;
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:15,代码来源:PSAssertReport.java


示例19: splitNumber

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
@Nonnull
public static String splitNumber (@Nonnull final StringBuilder aPattern)
{
  // Find the longest matching number within the pattern
  final Matcher m = RegExHelper.getMatcher (SPLIT_NUMBER_REGEX, aPattern.toString ());
  if (m.matches ())
    return m.group (1);
  return "";
}
 
开发者ID:phax,项目名称:ph-css,代码行数:10,代码来源:CSSParseHelper.java


示例20: getRectValues

import com.helger.commons.regex.RegExHelper; //导入依赖的package包/类
/**
 * Get all the values from within a CSS rectangle definition.
 *
 * @param sCSSValue
 *        The CSS values to check. May be <code>null</code>.
 * @return <code>null</code> if the passed String is not a CSS rectangle. An
 *         array with 4 Strings if the passed value is a CSS rectangle.
 */
@Nullable
public static String [] getRectValues (@Nullable final String sCSSValue)
{
  String [] ret = null;
  final String sRealValue = StringHelper.trim (sCSSValue);
  if (StringHelper.hasText (sRealValue))
  {
    ret = RegExHelper.getAllMatchingGroupValues (PATTERN_CURRENT_SYNTAX, sRealValue);
    if (ret == null)
      ret = RegExHelper.getAllMatchingGroupValues (PATTERN_OLD_SYNTAX, sRealValue);
  }
  return ret;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:22,代码来源:CSSRectHelper.java



注:本文中的com.helger.commons.regex.RegExHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntHolder类代码示例发布时间:2022-05-22
下一篇:
Java CanScrollVerticallyDelegate类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap