Package java.util.regex

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


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


       
        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();
        stringBuilder.append(chars);
View Full Code Here

        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();
        assertEquals(0, matchResult.start());
View Full Code Here

        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();
        assertEquals(0, matchResult.start());
View Full Code Here

        // 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.
            builder.append(name.substring(end - 1, end).toLowerCase());
View Full Code Here

      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));
      Assert.assertEquals(-1, m.end(2));
      Assert.assertEquals(m.end(), result.end());
      Assert.assertEquals(m.end(1), result.end(1));
      Assert.assertEquals(m.end(2), result.end(2));
   }

   @Test
View Full Code Here

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

   @Test
   public void shouldPeekPreviousWithNegativeNumber() throws Exception {
View Full Code Here

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

   @Test
   public void shouldPeekPreviousWithNegativeNumber() throws Exception {
      String source = "abcd";
View Full Code Here

        int byteCount = 0;
        int matches = 0;
        while ((matches < maxCount) && (line = reader.readLine()) != null) {
            result = match(line);
            if (result != null) {
                printMatch(line.substring(result.start(), result.end()),
                           name, reader.getLineNumber(), byteCount + result.start());
                rc = 0;
                matches++;
            }
            byteCount += line.length();
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.