Tabnine Logo
Pattern.quote
Code IndexAdd Tabnine to your IDE (free)

How to use
quote
method
in
java.util.regex.Pattern

Best Java code snippets using java.util.regex.Pattern.quote (Showing top 20 results out of 11,979)

Refine searchRefine arrow

  • Pattern.compile
  • Pattern.matcher
  • Matcher.find
  • Matcher.group
  • PrintStream.println
origin: stackoverflow.com

Pattern.compile(Pattern.quote(s2), Pattern.CASE_INSENSITIVE).matcher(s1).find();
origin: stackoverflow.com

 String pattern1 = "hgb";
String pattern2 = "|";
String text = "sdfjsdkhfkjsdf hgb sdjfkhsdkfsdf |sdfjksdhfjksd sdf sdkjfhsdkf | sdkjfh hgb sdkjfdshfks|";

Pattern p = Pattern.compile(Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2));
Matcher m = p.matcher(text);
while (m.find()) {
 System.out.println(m.group(1));
}
origin: stackoverflow.com

 String delim = "|";
String esc = "+";
String regex = "(?<!" + Pattern.quote(esc) + ")" + Pattern.quote(delim);

for (String s : "A|B|C|The Steading+|Keir Allan+|Braco|E".split(regex))
  System.out.println(s);
origin: stanfordnlp/CoreNLP

public void bindStringRegex(String var, String regex)
{
 // Enforce requirements on variable names ($alphanumeric_)
 if (!STRING_REGEX_VAR_NAME_PATTERN.matcher(var).matches()) {
  throw new IllegalArgumentException("StringRegex binding error: Invalid variable name " + var);
 }
 Pattern varPattern = Pattern.compile(Pattern.quote(var));
 String replace = Matcher.quoteReplacement(regex);
 stringRegexVariables.put(var, new Pair<>(varPattern, replace));
}
origin: stanfordnlp/CoreNLP

SystemUtils.run(process, outputWriter, null);
String output = outputWriter.getBuffer().toString();
Pattern docClose = Pattern.compile("</DOC>.*", Pattern.DOTALL);
output = docClose.matcher(output).replaceAll("</DOC>").replaceAll("<!DOCTYPE TimeML SYSTEM \"TimeML.dtd\">",""); //TODO TimeML.dtd? FileNotFoundException if we leave it in
Pattern badNestedTimex = Pattern.compile(Pattern.quote("<T</TIMEX3>IMEX3"));
output = badNestedTimex.matcher(output).replaceAll("</TIMEX3><TIMEX3");
Pattern badNestedTimex2 = Pattern.compile(Pattern.quote("<TI</TIMEX3>MEX3"));
output = badNestedTimex2.matcher(output).replaceAll("</TIMEX3><TIMEX3");
document.set(TimeAnnotations.TimexAnnotations.class, timexAnns);
if (outputResults) {
 System.out.println(timexAnns);
origin: stackoverflow.com

 import java.util.Arrays;
import java.util.regex.Pattern;
public class SplitExample {
  public static final String PLAYER = "1||1||Abdul-Jabbar||Karim||1996||1974";
  public static void main(String[] args) {
    String[] data = PLAYER.split("\\|\\|");
    System.out.println(Arrays.toString(data));

    Pattern pattern = Pattern.compile("\\|\\|");
    data = pattern.split(PLAYER);
    System.out.println(Arrays.toString(data));

    pattern = Pattern.compile(Pattern.quote("||"));
    data = pattern.split(PLAYER);
    System.out.println(Arrays.toString(data));
  }
}
origin: spring-projects/spring-data-mongodb

  return PUNCTATION_PATTERN.matcher(source).find() ? Pattern.quote(source) : source;
    trailingWildcard ? source.length() - 1 : source.length());
if (PUNCTATION_PATTERN.matcher(valueToUse).find()) {
  valueToUse = Pattern.quote(valueToUse);
origin: stanfordnlp/CoreNLP

private String toStringDep() {
 String str = "";
 if(classORrestrictions!= null && !this.classORrestrictions.isEmpty()) {
  for (Map.Entry<Class, String> en : this.classORrestrictions.entrySet()) {
   String orgVal = en.getValue().toString();
   String val;
   if(!alphaNumeric.matcher(orgVal).matches())
    val = "/" + Pattern.quote(orgVal.replaceAll("/","\\\\/"))+ "/";
   else
    val = orgVal;
   if (str.isEmpty())
    str = "{" + class2KeyMapping.get(en.getKey()) + ":" + val + "}";
   else
    str += " | " + "{" + class2KeyMapping.get(en.getKey()) + ":" + val + "}";
  }
 }
 return str.trim();
}
origin: stackoverflow.com

map.put(Pattern.compile(Pattern.quote(smile)), resource);
for (Entry<Pattern, Integer> entry : emoticons.entrySet()) {
  Matcher matcher = entry.getKey().matcher(spannable);
  while (matcher.find()) {
    boolean set = true;
    for (ImageSpan span : spannable.getSpans(matcher.start(),
origin: apache/flink

private int extractMaxIndex(String key, String suffixPattern) {
  // extract index and property keys
  final String escapedKey = Pattern.quote(key);
  final Pattern pattern = Pattern.compile(escapedKey + "\\.(\\d+)" + suffixPattern);
  final IntStream indexes = properties.keySet().stream()
    .flatMapToInt(k -> {
      final Matcher matcher = pattern.matcher(k);
      if (matcher.find()) {
        return IntStream.of(Integer.valueOf(matcher.group(1)));
      }
      return IntStream.empty();
    });
  // determine max index
  return indexes.max().orElse(-1);
}
origin: stackoverflow.com

System.out.println(haystack.matches("(?i)" + Pattern.quote(needle) + ".*"));
origin: SonarSource/sonarqube

private Collection<RuleRepositoryDto> listMatchingRepositories(@Nullable String query, @Nullable String languageKey) {
 Pattern pattern = Pattern.compile(query == null ? MATCH_ALL : MATCH_ALL + Pattern.quote(query) + MATCH_ALL, Pattern.CASE_INSENSITIVE);
 return selectFromDb(languageKey).stream()
  .filter(r -> pattern.matcher(r.getKey()).matches() || pattern.matcher(r.getName()).matches())
  .collect(MoreCollectors.toList());
}
origin: stackoverflow.com

Pattern.compile(Pattern.quote(s2), Pattern.CASE_INSENSITIVE).matcher(s1).find();
origin: stanfordnlp/CoreNLP

 PatternFactory.ignoreWordRegex = Pattern.compile(wordIgnoreRegex);
 System.out.println("Reading english words from " + englishWordsFiles);
 for (String englishWordsFile : englishWordsFiles.split("[;,]"))
  englishWords.addAll(IOUtils.linesFromFile(englishWordsFile));
 System.out.println("Size of othersemantic class variables is "
  + otherSemanticClassesWords.size());
} else {
 otherSemanticClassesWords = Collections.synchronizedSet(new HashSet<>());
 System.out.println("Size of othersemantic class variables is " + 0);
 if (i > 0)
  stopStr += "|";
 stopStr += Pattern.quote(s.getPhrase().replaceAll("\\\\", "\\\\\\\\"));
 i++;
origin: primefaces/primefaces

public static String getValidFilename(String filename) {
  if (LangUtils.isValueBlank(filename)) {
    return null;
  }
  if (isSystemWindows()) {
    if (!filename.contains("\\\\")) {
      String[] parts = filename.substring(FilenameUtils.getPrefixLength(filename)).split(Pattern.quote(File.separator));
      for (String part : parts) {
        if (INVALID_FILENAME_PATTERN.matcher(part).find()) {
          throw new FacesException("Invalid filename: " + filename);
        }
      }
    }
    else {
      throw new FacesException("Invalid filename: " + filename);
    }
  }
  String name = FilenameUtils.getName(filename);
  String extension = FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(filename);
  if (extension.equals(FilenameUtils.EXTENSION_SEPARATOR_STR)) {
    throw new FacesException("File must have an extension");
  }
  else if (name.isEmpty() || extension.equals(name)) {
    throw new FacesException("Filename can not be the empty string");
  }
  return name;
}
origin: stanfordnlp/CoreNLP

public static String getExctWsRegex(String targetString) {
 StringBuilder sb = new StringBuilder();
 String[] fields = whitespacePattern.split(targetString);
 for (String field:fields) {
  // require at least one whitespace if there is whitespace in target string
  if (sb.length() > 0) {
   sb.append("\\s+");
  }
  // Allow any number of spaces between punctuation and text
  String tmp = punctWhitespacePattern.matcher(field).replaceAll(" $1 ");
  tmp = tmp.trim();
  String[] punctFields = whitespacePattern.split(tmp);
  for (String f:punctFields) {
   if (sb.length() > 0) {
    sb.append("\\s*");
   }
   sb.append(Pattern.quote(f));
  }
 }
 return sb.toString();
}
origin: stanfordnlp/CoreNLP

/**
 * Takes an input String, and replaces any bash-style variables (e.g., $VAR_NAME)
 * with its actual environment variable from the passed environment specification.
 *
 * @param raw The raw String to replace variables in.
 * @param env The environment specification; e.g., {@link System#getenv()}.
 * @return The input String, but with all variables replaced.
 */
public static String expandEnvironmentVariables(String raw, Map<String, String> env) {
 String pattern = "\\$\\{?([a-zA-Z_]+[a-zA-Z0-9_]*)\\}?";
 Pattern expr = Pattern.compile(pattern);
 String text = raw;
 Matcher matcher = expr.matcher(text);
 while (matcher.find()) {
  String envValue = env.get(matcher.group(1));
  if (envValue == null) {
   envValue = "";
  } else {
   envValue = envValue.replace("\\", "\\\\");
  }
  Pattern subexpr = Pattern.compile(Pattern.quote(matcher.group(0)));
  text = subexpr.matcher(text).replaceAll(envValue);
 }
 return text;
}
origin: stackoverflow.com

 String delim = "|";
String regex = "(?<!\\\\)" + Pattern.quote(delim);

for (String s : "A|B|C|The Steading\\|Keir Allan\\|Braco|E".split(regex))
  System.out.println(s);
origin: SonarSource/sonarqube

private Collection<Language> listMatchingLanguages(@Nullable String query, int pageSize) {
 Pattern pattern = Pattern.compile(query == null ? MATCH_ALL : MATCH_ALL + Pattern.quote(query) + MATCH_ALL, Pattern.CASE_INSENSITIVE);
 SortedMap<String, Language> languagesByName = Maps.newTreeMap();
 for (Language lang : languages.all()) {
  if (pattern.matcher(lang.getKey()).matches() || pattern.matcher(lang.getName()).matches()) {
   languagesByName.put(lang.getName(), lang);
  }
 }
 List<Language> result = Lists.newArrayList(languagesByName.values());
 if (pageSize > 0 && pageSize < result.size()) {
  result = result.subList(0, pageSize);
 }
 return result;
}
origin: apache/ignite

/**
 * Create filter instance.
 *
 * @param caseSensitive Case sensitive flag.
 * @param regex Regex search flag.
 * @param ptrn String to search in string presentation of key or value.
 */
public VisorQueryScanRegexFilter(boolean caseSensitive, boolean regex, String ptrn) {
  int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE;
  this.ptrn = Pattern.compile(regex ? ptrn : ".*?" + Pattern.quote(ptrn) + ".*?", flags);
}
/**
java.util.regexPatternquote

Javadoc

Quotes the given string using "\Q" and "\E", so that all meta-characters lose their special meaning. This method correctly escapes embedded instances of "\Q" or "\E". If the entire result is to be passed verbatim to #compile, it's usually clearer to use the #LITERAL flag instead.

Popular methods of Pattern

  • matcher
    Creates a matcher that will match the given input against this pattern.
  • compile
  • split
    Splits the given input sequence around matches of this pattern. The array returned by this method co
  • pattern
  • matches
  • toString
    Returns the string representation of this pattern. This is the regular expression from which this pa
  • flags
    Returns this pattern's match flags.
  • splitAsStream
  • asPredicate
  • <init>
    This private constructor is used to create all Patterns. The pattern string and match flags are all
  • closeImpl
  • compileImpl
  • closeImpl,
  • compileImpl,
  • closure,
  • error,
  • escape,
  • RemoveQEQuoting,
  • accept,
  • addFlag,
  • append

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now