public RegexFunction() { templatePattern = JMeterUtils.getPatternCache().getPattern(TEMPLATE_PATTERN, Perl5Compiler.READ_ONLY_MASK); }
/** * create a new pattern object from the string. * * @param pattern * string representation of the perl5 compatible regex pattern * @return compiled Pattern, or <code>null</code> if no pattern could be * compiled */ public Pattern createPattern(String pattern) { try { return JMeterUtils.getPatternCache().getPattern(pattern, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); } catch (MalformedCachePatternException exception) { log.error("Problem with pattern: "+pattern,exception); return null; } }
/** * Match the input argument against the pattern using String.equals() or pattern matching if that fails * using case-insensitive matching. * * @param arg input string * @param pat pattern string * * @return true if input matches the pattern */ public static boolean isEqualOrMatches(String arg, String pat){ return isEqualOrMatches(arg, pat, JMeterUtils.getMatcher(), JMeterUtils.getPatternCache()); }
/** * Match the input argument against the pattern using String.equals() or pattern matching if that fails * using case-insensitive matching. * * @param arg input string * @param pat pattern string * * @return true if input matches the pattern */ public static boolean isEqualOrMatchesCaseBlind(String arg, String pat){ return isEqualOrMatchesCaseBlind(arg, pat, JMeterUtils.getMatcher(), JMeterUtils.getPatternCache()); }
private void initRegex(String argName) { pathExtensionEqualsQuestionmarkRegexp = JMeterUtils.getPatternCache().getPattern( SEMI_COLON + quotedArg + "=([^\"'<>&\\s;]*)", // $NON-NLS-1$ Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK); pathExtensionEqualsNoQuestionmarkRegexp = JMeterUtils.getPatternCache().getPattern( SEMI_COLON + quotedArg + "=([^\"'<>&\\s;?]*)", // $NON-NLS-1$ Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK); pathExtensionNoEqualsQuestionmarkRegexp = JMeterUtils.getPatternCache().getPattern( SEMI_COLON + quotedArg + "([^\"'<>&\\s;]*)", // $NON-NLS-1$ Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK); pathExtensionNoEqualsNoQuestionmarkRegexp = JMeterUtils.getPatternCache().getPattern( SEMI_COLON + quotedArg + "([^\"'<>&\\s;?]*)", // $NON-NLS-1$ Perl5Compiler.MULTILINE_MASK | Perl5Compiler.READ_ONLY_MASK); parameterRegexp = JMeterUtils.getPatternCache().getPattern(
/** * 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 : {} on sampleContentType: {}, expected to match: {}", expression, sampleContentType, expectedToMatch); } Pattern pattern = null; 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; }
private boolean isFirstElementGroup(String rawData) { Pattern pattern = JMeterUtils.getPatternCache().getPattern("^\\$\\d+\\$", //$NON-NLS-1$ Perl5Compiler.READ_ONLY_MASK); return JMeterUtils.getMatcher().contains(rawData, pattern); }
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; }
String rawTemplate = getTemplate(); PatternMatcher matcher = JMeterUtils.getMatcher(); Pattern templatePattern = JMeterUtils.getPatternCache().getPattern("\\$(\\d+)\\$" // $NON-NLS-1$ , Perl5Compiler.READ_ONLY_MASK & Perl5Compiler.SINGLELINE_MASK);
private boolean isEquals(String subj) { Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue()); return JMeterUtils.getMatcher().matches(subj, pattern); }
private String filterString(final String content) { if (stringsToSkip == null || stringsToSkip.isEmpty()) { return content; } else { String result = content; for (SubstitutionElement regex : stringsToSkip) { emptySub.setSubstitution(regex.getSubstitute()); result = Util.substitute(JMeterUtils.getMatcher(), JMeterUtils.getPatternCache().getPattern(regex.getRegex()), emptySub, result, Util.SUBSTITUTE_ALL); } return result; } }
private boolean isEquals(Object subj) { String str = JSONPathExtractor.objectToString(subj); if (isUseRegex()) { Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue()); return JMeterUtils.getMatcher().matches(str, pattern); } else { return str.equals(getExpectedValue()); } }
protected String getIpAddress(String logLine) { Pattern incIp = JMeterUtils.getPatternCache().getPattern("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK); Perl5Matcher matcher = JMeterUtils.getMatcher(); matcher.contains(logLine, incIp); return matcher.getMatch().group(0); }
private boolean isEquals(Object subj) { String str = objectToString(subj); if (isUseRegex()) { Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue()); return JMeterUtils.getMatcher().matches(str, pattern); } else { return str.equals(getExpectedValue()); } }
org.apache.oro.text.regex.Pattern regex = JMeterUtils.getPatternCache().getPattern(entry.getKey()); PatternMatcher matcher = JMeterUtils.getMatcher(); if (sampleName != null && matcher.matches(sampleName, regex)) {
pattern=JMeterUtils.getPatternCache().getPattern( REGEXP, Perl5Compiler.CASE_INSENSITIVE_MASK
final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();
public static void extractStyleURLs(final URL baseUrl, final URLCollection urls, String styleTagStr) { Perl5Matcher matcher = JMeterUtils.getMatcher(); Pattern pattern = JMeterUtils.getPatternCache().getPattern( "URL\\(\\s*('|\")(.*)('|\")\\s*\\)", // $NON-NLS-1$ Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK | Perl5Compiler.READ_ONLY_MASK); PatternMatcherInput input = null; input = new PatternMatcherInput(styleTagStr); while (matcher.contains(input, pattern)) { MatchResult match = matcher.getMatch(); // The value is in the second group String styleUrl = match.group(2); urls.addURL(styleUrl, baseUrl); } } }
/** * Arguments match if the input name matches the corresponding pattern name * and the input value matches the pattern value, where the matching is done * first using String equals, and then Regular Expression matching if the equals test fails. * * @param arg - input Argument * @param patternArg - pattern to match against * @return true if both name and value match */ public static boolean isArgumentMatched(Argument arg, Argument patternArg) { final Perl5Matcher matcher = JMeterUtils.getMatcher(); final PatternCacheLRU patternCache = JMeterUtils.getPatternCache(); return isEqualOrMatches(arg.getName(), patternArg.getName(), matcher, patternCache) && isEqualOrMatches(arg.getValue(), patternArg.getValue(), matcher, patternCache); }
Perl5Matcher matcher = JMeterUtils.getMatcher(); PatternMatcherInput input = new PatternMatcherInput(headerLine); Pattern pattern = JMeterUtils.getPatternCache()