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

        String s2 = "Logabcd ";
        m = pat.matcher(s2);
        assertFalse(m.find());

        String s3 = "abcdLogabcd ";
        m = pat.matcher(s3);
        assertFalse(m.find());

        String s4 = "abcdLog";
        m = pat.matcher(s4);
        assertFalse(m.find());

        String s5 = "Log myLog";
        m = pat.matcher(s5);
        assertFalse(m.find());

        Pattern pat2 = Pattern.compile("^Log\\b");
        Matcher m2 = pat2.matcher(s5);
        assertTrue(m2.find());
        r = m2.replaceAll("Logger");
        assertEquals("Logger myLog", r);
    }
In this test we try to replace keyword Log without influence on String
containing Log We see that we have to use two different Patterns
slf4j-migrator/src/test/java/org/slf4j/migrator/AternativeApproach.java