Package java.util.regex

Examples of java.util.regex.Matcher.region()


    while (m.find()) {
      final int start = m.start(), end = m.end();

      replace(start, end, replace);
      m.region(start + replaceLength, length());
    }

    return this;
  }
View Full Code Here


    while (m.find()) {
      final int start = m.start(), end = m.end();

      delete(start, end);
      m.region(start, length());
    }

    return this;
  }
View Full Code Here

    public void testMatchesRegionChanged() {
        // Regression for HARMONY-610
        String input = " word ";
        Pattern pattern = Pattern.compile("\\w+");
        Matcher matcher = pattern.matcher(input);
        matcher.region(1, 5);
        assertTrue(matcher.matches());
    }

    @Test
    public void testFindRegionChanged() {
View Full Code Here

        Matcher matcher = pattern.matcher("abcde");
        matcher.find();
        assertEquals("abcde", matcher.group());

        matcher = pattern.matcher("abcde");
        matcher.region(0, 2);
        matcher.find();
        assertEquals("ab", matcher.group());

    }
View Full Code Here

        // Regression for HARMONY-713
        Pattern pattern = Pattern.compile("c");

        String inputStr = "aabb.c";
        Matcher matcher = pattern.matcher(inputStr);
        matcher.region(0, 3);

        assertFalse(matcher.find());
    }

    @Test
View Full Code Here

    public void testRegionsIntInt() {
        Pattern p = Pattern.compile("x*");
        Matcher m = p.matcher("axxxxxa");
        assertFalse(m.matches());

        m.region(1, 6);
        assertEquals(1, m.regionStart());
        assertEquals(6, m.regionEnd());
        assertTrue(m.matches());

        try {
View Full Code Here

        assertEquals(1, m.regionStart());
        assertEquals(6, m.regionEnd());
        assertTrue(m.matches());

        try {
            m.region(1, 0);
            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
View Full Code Here

            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
            m.region(-1, 2);
            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
View Full Code Here

            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
            m.region(10, 11);
            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
View Full Code Here

            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }

        try {
            m.region(1, 10);
            fail("expected an IOOBE");
        } catch(IndexOutOfBoundsException e) {
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.