Example usage for java.util.regex Pattern CASE_INSENSITIVE

List of usage examples for java.util.regex Pattern CASE_INSENSITIVE

Introduction

In this page you can find the example usage for java.util.regex Pattern CASE_INSENSITIVE.

Prototype

int CASE_INSENSITIVE

To view the source code for java.util.regex Pattern CASE_INSENSITIVE.

Click Source Link

Document

Enables case-insensitive matching.

Usage

From source file:com.andrada.sitracker.reader.SamlibAuthorPageReader.java

@NotNull
@Override//from w w  w  . ja v  a 2 s.c  o  m
public List<Publication> getPublications(@NotNull Author author) {
    ArrayList<Publication> publicationList = new ArrayList<Publication>();
    Pattern pattern = Pattern.compile(Constants.PUBLICATIONS_REGEX, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(pageContent);
    while (matcher.find()) {

        Publication item = new Publication();
        String baseUrl = author.getUrl().replace(Constants.AUTHOR_PAGE_URL_ENDING_WI_SLASH, "");
        baseUrl = baseUrl.replace(Constants.AUTHOR_PAGE_ALT_URL_ENDING_WI_SLASH, "");

        item.setAuthor(author);
        item.setUpdateDate(new Date());
        //Group 1 - LinkToText
        String itemURL = matcher.group(3) == null ? "" : matcher.group(3);
        item.setUrl(baseUrl + "/" + itemURL);
        //Group 2 - NameOfText
        String itemTitle = matcher.group(4) == null ? "" : matcher.group(4);
        item.setName(escapeHTML(itemTitle));
        //Group 3 - SizeOfText
        String sizeOfText = matcher.group(5) == null ? "0" : matcher.group(5);
        item.setSize(Integer.parseInt(sizeOfText));
        //Group 4 - DescriptionOfRating
        String descriptionOfRating = matcher.group(6) == null ? "" : matcher.group(6);
        item.setRating(escapeHTML(descriptionOfRating));
        //Group 5 - Rating
        String rating = matcher.group(7) == null ? "0" : matcher.group(7);
        //Group 6 - Section
        String categoryName = matcher.group(8) == null ? "" : matcher.group(8);
        item.setCategory(escapeHTML(categoryName).replace("@", ""));
        //Group 7 - Genres
        String genre = matcher.group(9) == null ? "" : matcher.group(9);
        //Group 8 - Link to Comments
        String commentsUrl = matcher.group(10) == null ? "" : matcher.group(10);
        item.setCommentUrl(commentsUrl);
        //Group 9 - CommentsDescription
        String commentsDescription = matcher.group(11) == null ? "" : matcher.group(11);
        //Group 10 - CommentsCount
        String commentsCount = matcher.group(12) == null ? "0" : matcher.group(12);
        item.setCommentsCount(Integer.parseInt(commentsCount));
        //Group 11 - Description
        String itemDescription = matcher.group(13) == null ? "" : matcher.group(13);
        item.setDescription(itemDescription.trim());
        item.setImageUrl(extractImage(itemDescription.trim()));
        String imagesPageUrl = matcher.group(14) == null ? null : matcher.group(14);
        item.setImagePageUrl(imagesPageUrl);
        publicationList.add(item);
    }
    return publicationList;
}

From source file:com.haulmont.yarg.formatters.impl.inline.HtmlContentInliner.java

public HtmlContentInliner() {
    tagPattern = Pattern.compile(REGULAR_EXPRESSION, Pattern.CASE_INSENSITIVE);
}

From source file:com.adguard.commons.lang.Wildcard.java

/**
 * Returns "true" if input text is matching wildcard.
 * This method first checking shortcut -- if shortcut exists in input string -- than it checks regexp.
 *
 * @param input Input string// www  .j  a v a  2 s. c om
 * @return true if input string matches wildcard
 */
public boolean matches(String input) {
    if (StringUtils.isEmpty(input)) {
        return false;
    }

    boolean matchCase = ((regexpOptions & Pattern.CASE_INSENSITIVE) == Pattern.CASE_INSENSITIVE);

    if (matchCase && !StringUtils.contains(input, shortcut)) {
        return false;
    }

    if (!matchCase && !StringUtils.containsIgnoreCase(input, shortcut)) {
        return false;
    }

    return regexp.matcher(input).matches();
}

From source file:org.kurento.room.demo.FixedNKmsManager.java

public synchronized void setAuthRegex(String regex) {
    this.authRegex = regex != null ? regex.trim() : null;
    if (authRegex != null && !authRegex.isEmpty()) {
        authPattern = Pattern.compile(authRegex, Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
    }/*w ww . j  a  va 2s . c  o m*/
}

From source file:com.romeikat.datamessie.core.processing.service.fulltext.query.QueryUtil.java

public FullTextQuery parseQuery(final String luceneQueryString, final Analyzer analyzer) {
    LOG.debug("Parsing query: {}", luceneQueryString);
    // Check if query is "n outof abc def ghi"
    final Pattern pattern = Pattern.compile("\\s*(\\d+)\\s+outof\\s+(.*)",
            Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
    final Matcher matcher = pattern.matcher(luceneQueryString);
    // Match => OUTOF query
    if (matcher.matches()) {
        final int k = Integer.parseInt(matcher.group(1));
        final String searchString = matcher.group(2);
        final List<String> queryTerms = parseUtil.parseTerms(searchString, analyzer, true);
        final OutOfQuery query = new OutOfQuery(k, queryTerms);
        LOG.debug("Detected {}", query);
        return query;
    }//  ww w.j a  v a2s.  co m
    // No match => Lucene query
    else {
        final LuceneQuery query = new LuceneQuery(luceneQueryString);
        LOG.debug("Detected {}", query);
        return query;
    }
}

From source file:com.omsalung.service.filter.JWTFilter.java

private String getToken(HttpServletRequest httpRequest) throws ServletException {
    String token = null;//from   w  w  w  . ja v  a2 s.  c  om
    final String authorizationHeader = httpRequest.getHeader("authorization");
    if (authorizationHeader == null) {
        throw new ServletException("Unauthorized: No Authorization header was found");
    }

    String[] parts = authorizationHeader.split(" ");
    if (parts.length != 2) {
        throw new ServletException("Unauthorized: Format is Authorization: Bearer [token]");
    }

    String scheme = parts[0];
    String credentials = parts[1];

    Pattern pattern = Pattern.compile("^Bearer$", Pattern.CASE_INSENSITIVE);
    if (pattern.matcher(scheme).matches()) {
        token = credentials;
    }
    return token;
}

From source file:fr.itinerennes.bundler.tasks.framework.AbstractCsvTask.java

/**
 * @param filename//from   w  w  w . ja va 2s  . com
 *            the final name of the generated file
 */
public AbstractCsvTask(final String filename) {
    final Pattern csv = Pattern.compile("\\.csv$", Pattern.CASE_INSENSITIVE);
    if (csv.matcher(filename).find()) {
        this.filename = filename;
    } else {
        this.filename = String.format("%s.csv", filename);
    }
}

From source file:com.moarub.util.PageTitleGetter.java

private void saveTitle(StringBuilder result) {
    Log.d("Resolving title", "Ready");
    if (result != null) {
        String newTitle = result.toString();
        newTitle.replaceAll("\\s+", " ");
        Pattern titleP = Pattern.compile("<title>(.*?)</title>", Pattern.CASE_INSENSITIVE);
        Matcher m = titleP.matcher(newTitle);
        if (m.find()) {
            fListener.onTitleUpdate(m.group(1).trim(), fURLTo);
        } else {// w ww.  j  av a 2  s .  c  o  m
            fListener.onTitleUpdate(null, fURLTo);
        }
    } else {
        fListener.onTitleUpdate(null, fURLTo);
    }
}

From source file:edu.umn.se.trap.rule.grantrule.SponsoredNoAlcoholRule.java

/**
 * @param expense/*from   w  w w .ja  v a  2  s.c om*/
 * @throws TrapException
 */
private void checkSponsoredAlcohol(Expense expense) throws TrapException {

    /*
     * Check to make sure the expense is an other expense.
     */
    if (expense.getType().equals(ExpenseType.OTHER)) {
        /*
         * Try to match "alcohol" in the justification field.
         */

        Pattern alcoholPattern = Pattern.compile(alcoholRegex, Pattern.CASE_INSENSITIVE);

        Matcher alcoholMatcher = alcoholPattern.matcher(expense.getJustification());

        // If alcohol is found, check the grants.
        if (alcoholMatcher.find()) {
            GrantSet grantSet = expense.getEligibleGrants();

            if (grantSet == null) {
                throw new TrapException("Invalid TrapForm object: grantSet was null.");
            }

            Set<FormGrant> grants = grantSet.getGrants();

            if (grants == null) {
                throw new TrapException("Invalid TrapForm object: grants was null.");
            }

            Iterator<FormGrant> grantIter = grants.iterator();

            while (grantIter.hasNext()) {
                FormGrant grant = grantIter.next();

                if (StringUtils.equalsIgnoreCase(grant.getAccountType(), "Sponsored")) {
                    // Remove the grant if it is a sponsored grant trying to
                    // cover alcohol.
                    grantSet.removeGrant(grant.getAccountName());
                }
            }
        }
    }

}

From source file:GIST.IzbirkomExtractor.AbbrList.java

/**
 * Adds an abbreviation and a set of its expansions to abbreviation list.
 * //w  ww  .j  ava2  s  . c  o  m
 * @param abbr_string
 * @param expansions
 */
protected void addAbbrev(String abbr_string, String[] expansions) {

    if (!abbrevs.containsKey(abbr_string)) {
        Abbreviation abbr = Abbreviation.createAbbreviation(abbr_string);
        Pattern pat = Pattern.compile("\\b" + abbr_string + "\\b",
                Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
        // FIXME: ignore case flag does not seem to work because abbreviations are retrieved by original case
        abbr.setPattern(pat);
        abbrevs.put(abbr_string, abbr);
    }
    abbrevs.get(abbr_string).addExpandions(expansions);

    expansionsPattern = abbreviationsPattern = null; /* reset the pattern to indicate modification  of the abbreviation list */
}