Package java.util.regex

Examples of java.util.regex.MatchResult.start()


        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(1, matchResult.end());
        result = s.nextLine();
        matchResult = s.match();
        assertEquals(1, matchResult.start());
        assertEquals(2, matchResult.end());
       
        s = new Scanner("123 test\n   ");
        int value = s.nextInt();
        assertEquals(123, value);
View Full Code Here


       
        s = new Scanner("test\r\ntest");
        boolean result = s.hasNextLine();
        assertTrue(result);
        MatchResult matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(6, matchResult.end());

        s = new Scanner("\u0085");
        result = s.hasNextLine();
        assertTrue(result);
View Full Code Here

        s = new Scanner("\u0085");
        result = s.hasNextLine();
        assertTrue(result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(1, matchResult.end());
       
        s = new Scanner("\u2028");
        result = s.hasNextLine();
        assertTrue(result);
View Full Code Here

       
        s = new Scanner("\u2028");
        result = s.hasNextLine();
        assertTrue(result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(1, matchResult.end());
       
        s = new Scanner("\u2029");
        result = s.hasNextLine();
        assertTrue(result);
View Full Code Here

        assertEquals(1, matchResult.end());
       
        s = new Scanner("test\n");
        assertTrue(s.hasNextLine());
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(5, matchResult.end());

        char[] chars = new char[2048];
        Arrays.fill(chars, 'a');
        StringBuilder stringBuilder = new StringBuilder();
View Full Code Here

        s = new Scanner(stringBuilder.toString());
        result = s.hasNextLine();
        assertTrue(result);

        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(2048, matchResult.end());

        s = new Scanner("\n\n\n");
        assertTrue(s.hasNextLine());
        matchResult = s.match();
View Full Code Here

        assertEquals(2048, matchResult.end());

        s = new Scanner("\n\n\n");
        assertTrue(s.hasNextLine());
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(1, matchResult.end());

        // The scanner will not advance any input.
        assertTrue(s.hasNextLine());
        matchResult = s.match();
View Full Code Here

        assertEquals(1, matchResult.end());

        // The scanner will not advance any input.
        assertTrue(s.hasNextLine());
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(1, matchResult.end());
    }
   
    protected void setUp() throws Exception {
        super.setUp();
View Full Code Here

        while (matcher.find())
        {
            MatchResult matchResult = matcher.toMatchResult();

            int start = matchResult.start();
            int end = matchResult.end();

            builder.append(name.substring(lastx, start + 1));
            builder.append("-");
            // TODO: An acronym (such as "URL") should not be lower cased here.
View Full Code Here

      Assert.assertEquals(m.group(2), result.group(2));

      // Verify group start returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.start(1));
      Assert.assertEquals(-1, m.start(2));
      Assert.assertEquals(m.start(), result.start());
      Assert.assertEquals(m.start(1), result.start(1));
      Assert.assertEquals(m.start(2), result.start(2));

      // Verify group end returned are the same. g 1/2 should be -1
      Assert.assertEquals(-1, m.end(1));
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.