public void test2() {
        Pattern pat = Pattern.compile("(Log)");
        String s = "abcd Log =";
        Matcher m = pat.matcher(s);
        assertTrue(m.find());
        String r = m.replaceAll("Logger");
        assertEquals("abcd Logger =", r);

        String s1 = "Log l = LogFactory.getLog(MyClass.class);";
        m = pat.matcher(s1);
        assertTrue(m.find());
        r = m.replaceAll("Logger");
        assertEquals("Logger l = LoggerFactory.getLogger(MyClass.class);", r);

        String s2 = "Logabc ";
        m = pat.matcher(s2);
        assertTrue(m.find());

        String s3 = "abcLog";
        m = pat.matcher(s3);
        assertTrue(m.find());
    }
In this test we replace, using the simple Pattern (Log), the full Log
declaration and instantiation. This is not convenient because we will also
replace all String containing "Log".
slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java