org.apache.oro.text.regex.Perl5Compiler Java Examples
The following examples show how to use
org.apache.oro.text.regex.Perl5Compiler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListChooseByNameModel.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Pattern getTaskPattern(String pattern) { if (!Comparing.strEqual(pattern, myPattern)) { myCompiledPattern = null; myPattern = pattern; } if (myCompiledPattern == null) { final String regex = "^.*" + NameUtil.buildRegexp(pattern, 0, true, true); final Perl5Compiler compiler = new Perl5Compiler(); try { myCompiledPattern = compiler.compile(regex); } catch (MalformedPatternException ignored) { } } return myCompiledPattern; }
Example #2
Source File: ValidatorUtil.java From webcurator with Apache License 2.0 | 6 votes |
/** * Helper method to validate the specified string does not contain anything other than * that specified by the regular expression * @param aErrors The errors object to populate * @param aValue the string to check * @param aRegEx the Perl based regular expression to check the value against * @param aErrorCode the error code for getting the i8n failure message * @param aValues the list of values to replace in the i8n messages * @param aFailureMessage the default error message */ public static void validateRegEx(Errors aErrors, String aValue, String aRegEx, String aErrorCode, Object[] aValues, String aFailureMessage) { if (aValue != null && aRegEx != null && !aRegEx.equals("") && !aValue.trim().equals("")) { Perl5Compiler ptrnCompiler = new Perl5Compiler(); Perl5Matcher matcher = new Perl5Matcher(); try { Perl5Pattern aCharPattern = (Perl5Pattern) ptrnCompiler.compile(aRegEx); if (!matcher.contains(aValue, aCharPattern)) { aErrors.reject(aErrorCode, aValues, aFailureMessage); return; } } catch (MalformedPatternException e) { LogFactory.getLog(ValidatorUtil.class).fatal("Perl pattern malformed: pattern used was "+aRegEx +" : "+ e.getMessage(), e); } } }
Example #3
Source File: JMeterProxyControl.java From jsflight with Apache License 2.0 | 6 votes |
private boolean matchesPatterns(String url, CollectionProperty patterns) { for (JMeterProperty jMeterProperty : patterns) { String item = jMeterProperty.getStringValue(); try { Pattern pattern = JMeterUtils.getPatternCache().getPattern(item, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); if (JMeterUtils.getMatcher().matches(url, pattern)) { return true; } } catch (MalformedCachePatternException e) { LOG.warn("Skipped invalid pattern: " + item, e); } } return false; }
Example #4
Source File: reReplace.java From openbd-core with GNU General Public License v3.0 | 6 votes |
protected String doRereplace( String _theString, String _theRE, String _theSubstr, boolean _casesensitive, boolean _replaceAll ) throws cfmRunTimeException{ int replaceCount = _replaceAll ? Util.SUBSTITUTE_ALL : 1; PatternMatcher matcher = new Perl5Matcher(); Pattern pattern = null; PatternCompiler compiler = new Perl5Compiler(); try { if ( _casesensitive ){ pattern = compiler.compile( _theRE, Perl5Compiler.SINGLELINE_MASK ); }else{ pattern = compiler.compile( _theRE, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK ); } } catch(MalformedPatternException e){ // definitely should happen since regexp is hardcoded cfCatchData catchD = new cfCatchData(); catchD.setType( "Function" ); catchD.setMessage( "Internal Error" ); catchD.setDetail( "Invalid regular expression ( " + _theRE + " )" ); throw new cfmRunTimeException( catchD ); } // Perform substitution and print result. return Util.substitute(matcher, pattern, new Perl5Substitution( processSubstr( _theSubstr ) ), _theString, replaceCount ); }
Example #5
Source File: PatternFactory.java From scipio-erp with Apache License 2.0 | 6 votes |
/** * Compiles and caches a Perl5 regexp pattern for the given string pattern. * This would be of no benefits (and may bloat memory usage) if stringPattern is never the same. * @param stringPattern a Perl5 pattern string * @param caseSensitive case sensitive true/false * @return a <code>Pattern</code> instance for the given string pattern * @throws MalformedPatternException */ public static Pattern createOrGetPerl5CompiledPattern(String stringPattern, boolean caseSensitive) throws MalformedPatternException { Pattern pattern = compiledPerl5Patterns.get(stringPattern); if (pattern == null) { Perl5Compiler compiler = new Perl5Compiler(); if (caseSensitive) { pattern = compiler.compile(stringPattern, Perl5Compiler.READ_ONLY_MASK); // READ_ONLY_MASK guarantees immutability } else { pattern = compiler.compile(stringPattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK); } pattern = compiledPerl5Patterns.putIfAbsentAndGet(stringPattern, pattern); if (Debug.verboseOn()) { Debug.logVerbose("Compiled and cached the pattern: '" + stringPattern, module); } } return pattern; }
Example #6
Source File: RegxpContain.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @param idx 指定提取位置 idx 指定提取位置 * @return return */ public List<String> fetch(String src, String regx, int idx) throws Exception{ List<String> list = new ArrayList<String>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.contains(input, pattern)){ MatchResult matchResult = matcher.getMatch(); list.add(matchResult.group(idx)); } }catch(Exception e){ log.error("[提取异常][src:{}][reg:{}]", src, regx); e.printStackTrace(); throw e; } return list; }
Example #7
Source File: RegxpContain.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @return return */ public List<List<String>> fetchs(String src, String regx){ List<List<String>> list = new ArrayList<List<String>>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.contains(input, pattern)){ MatchResult matchResult = matcher.getMatch(); int groups = matchResult.groups(); List<String> item = new ArrayList<String>(); for(int i=0; i<groups; i++){ item.add(matchResult.group(i)); } list.add(item); } }catch(Exception e){ log.error("[提取异常][src:{}][reg:{}]", src, regx); e.printStackTrace(); } return list; }
Example #8
Source File: RegularContain.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @param idx 指定提取位置 idx 指定提取位置 * @return return */ public List<String> fetch(String src, String regx, int idx) throws Exception{ List<String> list = new ArrayList<String>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.contains(input, pattern)){ MatchResult matchResult = matcher.getMatch(); list.add(matchResult.group(idx)); } }catch(Exception e){ log.error("[提取异常][src:{}][reg:{}]", src, regx); if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } throw e; } return list; }
Example #9
Source File: RegularContain.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @return return */ public List<List<String>> fetchs(String src, String regx){ List<List<String>> list = new ArrayList<List<String>>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.contains(input, pattern)){ MatchResult matchResult = matcher.getMatch(); int groups = matchResult.groups(); List<String> item = new ArrayList<String>(); for(int i=0; i<groups; i++){ item.add(matchResult.group(i)); } list.add(item); } }catch(Exception e){ log.error("[提取异常][src:{}][reg:{}]", src, regx); if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } } return list; }
Example #10
Source File: RegularMatchPrefix.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @param idx 指定提取位置 idx 指定提取位置 * @return return */ public List<String> fetch(String src, String regx, int idx){ List<String> list = new ArrayList<String>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.matchesPrefix(input, pattern)){ MatchResult matchResult = matcher.getMatch(); list.add(matchResult.group(idx)); } }catch(Exception e){ if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } } return list; }
Example #11
Source File: RegularMatchPrefix.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @return return */ public List<List<String>> fetchs(String src, String regx){ List<List<String>> list = new ArrayList<List<String>>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.matchesPrefix(input, pattern)){ MatchResult matchResult = matcher.getMatch(); int groups = matchResult.groups(); List<String> item = new ArrayList<String>(); for(int i=0; i<=groups; i++){ item.add(matchResult.group(i)); } list.add(item); } }catch(Exception e){ if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } } return list; }
Example #12
Source File: RegularUtil.java From anyline with Apache License 2.0 | 6 votes |
/** * 字符串下标 regx在src中首次出现的位置 * @param src src * @param regx regx * @param begin 有效开始位置 * @return return */ public static int indexOf(String src, String regx, int begin){ int idx = -1; try{ PatternCompiler patternCompiler = new Perl5Compiler(); Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.contains(input, pattern)){ MatchResult matchResult = matcher.getMatch(); int tmp = matchResult.beginOffset(0); if(tmp >= begin){//匹配位置从begin开始 idx = tmp; break; } } }catch(Exception e){ log.error("[提取异常][src:{}][regx:{}]", src, regx); e.printStackTrace(); } return idx; }
Example #13
Source File: RegularMatch.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @param idx 指定提取位置 idx 指定提取位置 * @return return */ public List<String> fetch(String src, String regx, int idx){ List<String> list = new ArrayList<String>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.DEFAULT_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.matches(input, pattern)){ MatchResult matchResult = matcher.getMatch(); list.add(matchResult.group(idx)); } }catch(Exception e){ if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } } return list; }
Example #14
Source File: RegularMatch.java From anyline with Apache License 2.0 | 6 votes |
/** * 提取子串 * @param src 输入字符串 src 输入字符串 * @param regx 表达式 regx 表达式 * @return return */ public List<List<String>> fetchs(String src, String regx){ List<List<String>> list = new ArrayList<List<String>>(); try{ Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.DEFAULT_MASK); PatternMatcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(src); while(matcher.matches(input, pattern)){ MatchResult matchResult = matcher.getMatch(); int groups = matchResult.groups(); List<String> item = new ArrayList<String>(); for(int i=0; i<=groups; i++){ item.add(matchResult.group(i)); } list.add(item); } }catch(Exception e){ if(ConfigTable.isDebug() && log.isWarnEnabled()){ e.printStackTrace(); } } return list; }
Example #15
Source File: RegexpStressTest.java From common-utils with GNU General Public License v2.0 | 5 votes |
public OroTester() throws Exception { patterns = new Pattern[exps.length]; for (int i = 0; i < patterns.length; i++) { patterns[i] = new Perl5Compiler().compile(exps[i], Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK); } }
Example #16
Source File: Perl5RegExpMatching.java From j2ssh-maverick with GNU Lesser General Public License v3.0 | 5 votes |
/** * compiles fileNameRegExp into a regular expression and pattern matches on * each file's name, and returns those that match. * * @param files * @param fileNameRegExp * * @return SftpFile[] of files that match the expresion. */ public SftpFile[] matchFilesWithPattern(SftpFile[] files, String fileNameRegExp) throws SftpStatusException, SshException { // set up variables for regexp matching Pattern mpattern = null; PatternCompiler aPCompiler = new Perl5Compiler(); PatternMatcher aPerl5Matcher = new Perl5Matcher(); // Attempt to compile the pattern. If the pattern is not valid, // throw exception try { mpattern = aPCompiler.compile(fileNameRegExp); } catch (MalformedPatternException e) { throw new SshException("Invalid regular expression:" + e.getMessage(), SshException.BAD_API_USAGE); } Vector<SftpFile> matchedNames = new Vector<SftpFile>(); for (int i = 0; i < files.length; i++) { if ((!files[i].getFilename().equals(".")) && (!files[i].getFilename().equals("..")) && (!files[i].isDirectory())) { if (aPerl5Matcher.matches(files[i].getFilename(), mpattern)) { // call get for each match, passing true, so that it doesnt // repeat the search matchedNames.addElement(files[i]); } } } // return (SftpFile[]) matchedNames.toArray(new SftpFile[0]); SftpFile[] matchedNamesSftpFiles = new SftpFile[matchedNames.size()]; matchedNames.copyInto(matchedNamesSftpFiles); return matchedNamesSftpFiles; }
Example #17
Source File: PatternUtils.java From canal with Apache License 2.0 | 5 votes |
public Pattern apply(String pattern) { try { PatternCompiler pc = new Perl5Compiler(); return pc.compile(pattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); } catch (MalformedPatternException e) { throw new RuntimeException(e); } }
Example #18
Source File: Perl5RegExpMatching.java From j2ssh-maverick with GNU Lesser General Public License v3.0 | 5 votes |
/** * compiles fileNameRegExp into a regular expression and pattern matches on * each file's name, and returns those that match. * * @param files * @param fileNameRegExp * * @return String[] of file names that match the expresion. */ public String[] matchFileNamesWithPattern(File[] files, String fileNameRegExp) throws SshException { // set up variables for regexp matching Pattern mpattern = null; PatternCompiler aPCompiler = new Perl5Compiler(); PatternMatcher aPerl5Matcher = new Perl5Matcher(); // Attempt to compile the pattern. If the pattern is not valid, // throw exception try { mpattern = aPCompiler.compile(fileNameRegExp); } catch (MalformedPatternException e) { throw new SshException("Invalid regular expression:" + e.getMessage(), SshException.BAD_API_USAGE); } Vector<String> matchedNames = new Vector<String>(); for (int i = 0; i < files.length; i++) { if ((!files[i].getName().equals(".")) && (!files[i].getName().equals("..")) && (!files[i].isDirectory())) { if (aPerl5Matcher.matches(files[i].getName(), mpattern)) { // call get for each match, passing true, so that it doesnt // repeat the search matchedNames.addElement(files[i].getName()); } } } // return (String[]) matchedNames.toArray(new String[0]); String[] matchedNamesStrings = new String[matchedNames.size()]; matchedNames.copyInto(matchedNamesStrings); return matchedNamesStrings; }
Example #19
Source File: cfCACHE.java From openbd-core with GNU General Public License v3.0 | 5 votes |
private static String escapeExpireUrl(String expireURL){ Perl5Compiler compiler = new Perl5Compiler(); Perl5Matcher matcher = new Perl5Matcher(); Pattern pattern = null; try{ pattern = compiler.compile( "([+?.])" ); expireURL = Util.substitute(matcher, pattern, new Perl5Substitution( "\\\\$1" ), expireURL, Util.SUBSTITUTE_ALL ); return com.nary.util.string.replaceString(expireURL,"*",".*"); }catch(Exception E){ return null; } }
Example #20
Source File: FileUtils.java From openbd-core with GNU General Public License v3.0 | 5 votes |
/** * These methods are for use by the CFDIRECTORY tag. * @throws MalformedPatternException */ public static List<Map<String, cfData>> createFileVector(File dir, String _pattern, boolean _recurse, int listType, int listInfo) throws MalformedPatternException { Pattern pattern = null; if ( _pattern != null ){ org.apache.oro.text.regex.Perl5Compiler perl = new org.apache.oro.text.regex.Perl5Compiler(); pattern = perl.compile( escapeFilter( _pattern ), Perl5Compiler.CASE_INSENSITIVE_MASK ); } if (listInfo == LIST_INFO_NAME) { return createFilenameVector(listFilenames(dir, "", pattern, _recurse, listType)); } else { return createFileVector(listFiles(dir, pattern, _recurse, listType), dir, _recurse); } }
Example #21
Source File: FileUtils.java From openbd-core with GNU General Public License v3.0 | 5 votes |
/** * Delete all files in the directory whose names match the specified pattern. * @throws MalformedPatternException */ public static void deleteFiles(String _dir, String _pattern) throws IOException, MalformedPatternException { org.apache.oro.text.regex.Perl5Compiler perl = new org.apache.oro.text.regex.Perl5Compiler(); Pattern pattern = perl.compile( escapeFilter( _pattern ), Perl5Compiler.CASE_INSENSITIVE_MASK ); try { File[] filesToDelete = new File(_dir).listFiles((FileFilter) new CustomFileFilter(pattern, false)); for (int i = 0; i < filesToDelete.length; i++) { filesToDelete[i].delete(); } } catch (Throwable t) { throw new IOException(t.getMessage()); } }
Example #22
Source File: string.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public static boolean regexMatches(String str, String re) throws MalformedPatternException { PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); PatternMatcherInput input = new PatternMatcherInput(str); Pattern pattern = compiler.compile(re, Perl5Compiler.SINGLELINE_MASK); return matcher.matches(input, pattern); }
Example #23
Source File: JMeterProxyControl.java From jsflight with Apache License 2.0 | 5 votes |
/** * Returns true if matching pattern was different from expectedToMatch * * @param expression Expression to match * @param sampleContentType * @return boolean true if Matching expression */ private boolean testPattern(String expression, String sampleContentType, boolean expectedToMatch) { if (expression != null && expression.length() > 0) { if (LOG.isDebugEnabled()) { LOG.debug("Testing Expression : " + expression + " on sampleContentType:" + sampleContentType + ", expected to match:" + expectedToMatch); } Pattern pattern; try { pattern = JMeterUtils.getPatternCache().getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); if (JMeterUtils.getMatcher().contains(sampleContentType, pattern) != expectedToMatch) { return false; } } catch (MalformedCachePatternException e) { LOG.warn("Skipped invalid content pattern: " + expression, e); } } return true; }
Example #24
Source File: string.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public static String escapeHtml(String str) { try { PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = compiler.compile("&(([a-z][a-zA-Z0-9]*)|(#\\d{2,6});)", Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK); String tmp = Util.substitute(matcher, pattern, new Perl5Substitution("&$1"), str, Util.SUBSTITUTE_ALL); return replaceChars(tmp, new char[] { '<', '>', '\"' }, new String[] { "<", ">", """ }); } catch (Exception e) { return str; }// won't happen }
Example #25
Source File: ValidatorUtil.java From webcurator with Apache License 2.0 | 5 votes |
/** * Helper method to validate a new password for a user id. * @param aErrors The errors object to populate * @param aNewPwd the new password for the user id * @param aErrorCode the error code * @param aValues the values * @param aFailureMessage the default message */ public static void validateNewPassword(Errors aErrors, String aNewPwd, String aErrorCode, Object[] aValues, String aFailureMessage) { if (aNewPwd != null && !aNewPwd.trim().equals("")) { Perl5Compiler ptrnCompiler = new Perl5Compiler(); Perl5Matcher matcher = new Perl5Matcher(); try { Perl5Pattern lcCharPattern = (Perl5Pattern) ptrnCompiler.compile("[a-z]"); Perl5Pattern ucCharPattern = (Perl5Pattern) ptrnCompiler.compile("[A-Z]"); Perl5Pattern numericPattern = (Perl5Pattern) ptrnCompiler.compile("[0-9]"); if (aNewPwd.length() < 6) { aErrors.reject(aErrorCode, aValues, aFailureMessage); return; } if (!matcher.contains(aNewPwd, lcCharPattern)) { aErrors.reject(aErrorCode, aValues, aFailureMessage); return; } if (!matcher.contains(aNewPwd, ucCharPattern)) { aErrors.reject(aErrorCode, aValues, aFailureMessage); return; } if (!matcher.contains(aNewPwd, numericPattern)) { aErrors.reject(aErrorCode, aValues, aFailureMessage); return; } } catch (MalformedPatternException e) { LogFactory.getLog(ValidatorUtil.class).fatal("Perl patterns malformed: " + e.getMessage(), e); } } }
Example #26
Source File: PatternUtils.java From binlake with Apache License 2.0 | 5 votes |
@Override public Pattern load(String pattern) throws Exception { try { PatternCompiler pc = new Perl5Compiler(); return pc.compile( pattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); } catch (MalformedPatternException e) { throw new NullPointerException("PatternUtils error!"); } }
Example #27
Source File: Perl5Regex.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * @param regex * the regular expression pattern to compile. * @throws PatternInvalidSyntaxException * if the regular expression's syntax is invalid. */ public Perl5Regex(String regex) { super(); Perl5Compiler perl5Compiler = new Perl5Compiler(); try { pattern = perl5Compiler.compile(regex); regexPattern = regex; } catch (MalformedPatternException malformedPatternException) { throw new PatternInvalidSyntaxException(malformedPatternException .getMessage()); } }
Example #28
Source File: PatternUtils.java From jlogstash-input-plugin with Apache License 2.0 | 5 votes |
@Override public Pattern apply(String pattern) { try { PatternCompiler pc = new Perl5Compiler(); return pc.compile(pattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); } catch (MalformedPatternException e) { throw new CanalFilterException(e); } }
Example #29
Source File: JavaSource.java From yugong with GNU General Public License v2.0 | 5 votes |
public Pattern apply(String pattern) { try { PatternCompiler pc = new Perl5Compiler(); return pc.compile(pattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK); } catch (MalformedPatternException e) { throw new RuntimeException("Regex failed!", e); } }
Example #30
Source File: PatternUtils.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public Pattern apply(String pattern) { try { PatternCompiler pc = new Perl5Compiler(); return pc.compile(pattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); } catch (MalformedPatternException e) { throw new RuntimeException(e); } }