Search in sources :

Example 86 with Pattern

use of java.util.regex.Pattern in project jimfs by google.

the class PathNormalizationTest method assertNormalizedPatternMatches.

/**
   * Asserts that the given strings match when one is compiled as a regex pattern using the current
   * normalizer and matched against the other.
   */
private void assertNormalizedPatternMatches(String first, String second) {
    Pattern pattern = PathNormalization.compilePattern(first, normalizations);
    assertTrue("pattern '" + pattern + "' does not match '" + second + "'", pattern.matcher(second).matches());
    pattern = PathNormalization.compilePattern(second, normalizations);
    assertTrue("pattern '" + pattern + "' does not match '" + first + "'", pattern.matcher(first).matches());
}
Also used : Pattern(java.util.regex.Pattern)

Example 87 with Pattern

use of java.util.regex.Pattern in project binnavi by google.

the class CBlockGenerator method createExpression.

@Override
public IFilterExpression<CViewWrapper> createExpression(final String text) {
    final Pattern pattern = Pattern.compile(RULE_REGEX);
    final Matcher matcher = pattern.matcher(text);
    matcher.matches();
    final FilterRelation predicate = FilterRelation.parse(matcher.group(1));
    final String value = matcher.group(2);
    return new CBlockFilterExpression(predicate, Long.valueOf(value));
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 88 with Pattern

use of java.util.regex.Pattern in project binnavi by google.

the class CEdgeGenerator method createExpression.

@Override
public IFilterExpression<CViewWrapper> createExpression(final String text) {
    final Pattern pattern = Pattern.compile(RULE_REGEX);
    final Matcher matcher = pattern.matcher(text);
    matcher.matches();
    final FilterRelation predicate = FilterRelation.parse(matcher.group(1));
    final String value = matcher.group(2);
    return new CEdgeFilterExpression(predicate, Long.valueOf(value));
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 89 with Pattern

use of java.util.regex.Pattern in project binnavi by google.

the class CModuleGenerator method createExpression.

@Override
public IFilterExpression<CAddressSpaceWrapper> createExpression(final String text) {
    final Pattern pattern = Pattern.compile(RULE_REGEX);
    final Matcher matcher = pattern.matcher(text);
    matcher.matches();
    final FilterRelation predicate = FilterRelation.parse(matcher.group(1));
    final String value = matcher.group(2);
    return new CModuleFilterExpression(predicate, Long.valueOf(value));
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 90 with Pattern

use of java.util.regex.Pattern in project binnavi by google.

the class ARMBaseTranslator method translateCondition.

private void translateCondition(final ITranslationEnvironment environment, final IInstruction instruction, final String prefix, final List<ReilInstruction> instructions, final int nopIndex) throws InternalTranslationException {
    final long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
    // check if instruction is conditional
    final Pattern condPattern = Pattern.compile(prefix + "(AL|CC|LO|CS|HS|EQ|GE|GT|HI|LE|LS|LT|MI|NE|NV|PL|VC|VS).{0,2}$");
    final Matcher condMatcher = condPattern.matcher(instruction.getMnemonic());
    if (condMatcher.matches()) {
        // conditional execution is found call condition generator
        final String jmpGoal = String.format("%d.%d", instruction.getAddress().toLong(), nopIndex);
        ConditionGenerator.generate(baseOffset, environment, instruction, instructions, condMatcher.group(1), jmpGoal);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Aggregations

Pattern (java.util.regex.Pattern)3181 Matcher (java.util.regex.Matcher)2116 ArrayList (java.util.ArrayList)387 IOException (java.io.IOException)247 Test (org.junit.Test)238 File (java.io.File)193 HashMap (java.util.HashMap)163 BufferedReader (java.io.BufferedReader)127 Field (java.lang.reflect.Field)119 PatternSyntaxException (java.util.regex.PatternSyntaxException)119 Map (java.util.Map)110 List (java.util.List)93 HashSet (java.util.HashSet)79 InputStreamReader (java.io.InputStreamReader)67 InputStream (java.io.InputStream)43 FileReader (java.io.FileReader)41 FileInputStream (java.io.FileInputStream)40 URL (java.net.URL)35 SmallTest (android.test.suitebuilder.annotation.SmallTest)31 LinkedHashMap (java.util.LinkedHashMap)31