@@ -0,0 +1,2672 @@
+/*%0A * Copyright 2016 %22Masahiko Sakamoto%22 %3Csakamoto.gsyc.3s@gmail.com%3E%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage javasnack.langspecs;%0A%0Aimport static org.testng.Assert.*;%0A%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0Aimport org.testng.annotations.Test;%0A%0Apublic class TestRegexp1 %7B%0A    @Test%0A    public void typicalPatternMatch() %7B%0A        Pattern p = Pattern.compile(%22hello%22);%0A        Matcher m = p.matcher(%22abc hello def%22);%0A        assertTrue(m.find());%0A        assertEquals(%22hello%22, m.group());%0A        assertEquals(4, m.start());%0A        assertEquals(9, m.end());%0A        m = p.matcher(%22abc hell def%22);%0A        assertFalse(m.find());%0A    %7D%0A%0A    @Test%0A    public void typicalPatternEscape() %7B%0A        Pattern p = Pattern.compile(%22%5C%5Cd%7B3%7D%22);%0A        Matcher m = p.matcher(%22abc 123 def%22);%0A        assertTrue(m.find());%0A        assertEquals(%22123%22, m.group());%0A        assertEquals(4, m.start());%0A        assertEquals(7, m.end());%0A        m = p.matcher(%22abc 12 def%22);%0A        assertFalse(m.find());%0A    %7D%0A%0A    @Test%0A    public void typicalPatternEscapeQE() %7B%0A        Pattern p = Pattern.compile(%22%5C%5CQ%5C%5Cd%7B3%7D%5C%5CE%22);%0A        Matcher m = p.matcher(%22abc %5C%5Cd%7B3%7D def%22);%0A        assertTrue(m.find());%0A        assertEquals(%22%5C%5Cd%7B3%7D%22, m.group());%0A        assertEquals(4, m.start());%0A        assertEquals(9, m.end());%0A    %7D%0A%0A    @Test%0A    public void embeddedFlagDemo() %7B%0A        Pattern p = Pattern.compile(%22(?im)(%5Eabc.*def$)%22);%0A        Matcher m = p.matcher(%22ABCxxxDEF%5Cnabc123def%5Cnab99ef%5CnaBcDeF%22);%0A        assertTrue(m.find());%0A        assertEquals(%22ABCxxxDEF%22, m.group());%0A        assertEquals(0, m.start());%0A        assertEquals(9, m.end());%0A        assertTrue(m.find());%0A        assertEquals(%22abc123def%22, m.group());%0A        assertEquals(10, m.start());%0A        assertEquals(19, m.end());%0A        assertTrue(m.find());%0A        assertEquals(%22aBcDeF%22, m.group());%0A        assertEquals(27, m.start());%0A        assertEquals(33, m.end());%0A    %7D%0A%0A    @Test%0A    public void quoteDemo() %7B%0A        assertEquals(%22%5C%5CQ%5C%5Cd%7B3%7D%5C%5CE%22, Pattern.quote(%22%5C%5Cd%7B3%7D%22));%0A        assertEquals(%22%5C%5CQ(?im)(%5Eabc.*def$)%5C%5CE%22, Pattern.quote(%22(?im)(%5Eabc.*def$)%22));%0A    %7D%0A%7D%0A

add TestRegexp1.java