Java String Escape addEscapeCapacityToRegex(String inputRegex)

Here you can find the source of addEscapeCapacityToRegex(String inputRegex)

Description

This will encode the given Regex string the capacity to ignore the escaped word, i.e.

License

Open Source License

Parameter

Parameter Description
inputRegex the Regex string to be added the capacity

Return

the new Regex that include the capacity to ignore the escaped word.

Declaration

public static String addEscapeCapacityToRegex(String inputRegex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final String ESCAPE_CHARACTER = ";";

    /**// ww  w.j  a va2  s. co  m
     * This will encode the given Regex string the capacity to ignore the 
     * escaped word, i.e. word preceded by the {@link ESCAPE_CHARACTER}.
     * 
     * @param inputRegex the Regex string to be added the capacity
     * @return the new Regex that include the capacity to ignore the escaped word.
     */
    public static String addEscapeCapacityToRegex(String inputRegex) {
        return String.format("(?<!%1$s)%2$s", ESCAPE_CHARACTER, inputRegex);
    }
}

Related

  1. addEscape(String a_unescaped)
  2. addEscapeChar(String str)
  3. addEscapeCharactersForSpaces(String s)
  4. addEscapeCharsToBackSlash(String code)
  5. addEscapes(String s)