Package java.util

Examples of java.util.Scanner.match()


        void parseMacKeyHeaderLine(String line, KatResult kr) {
            Scanner ls = new Scanner(line);
            ls.findInLine(".*=\\s*(\\d+) .*");
            MatchResult result = null;
            try {
                result = ls.match();
            } catch (Exception e) {
                System.out.println("Mac header: " + line);
                e.printStackTrace();
                System.exit(1);
            }
View Full Code Here


            Scanner lineScanner = new Scanner(line);
            lineScanner
                    .findInLine(":Skein-(\\d+):\\s*(\\d+)-.*=\\s*(\\d+) bits(.*)");
            MatchResult result = null;
            try {
                result = lineScanner.match();
            } catch (Exception e) {
                System.out.println("Header line: " + line);
                e.printStackTrace();
                System.exit(1);
            }
View Full Code Here

            // Split into "proxyAddr:proxyPort".
            proxyAddr = null;
            int proxyPort = 8080;
            try {
                s.findInLine("(http://|)([^:/]+)(:|)([0-9]*)(/|)");
                MatchResult m = s.match();
                if (m.groupCount() >= 2) {
                    proxyAddr = m.group(2);
                }
                if ((m.groupCount() >= 4) && (!m.group(4).isEmpty())) {
                    proxyPort = Integer.parseInt(m.group(4));
View Full Code Here

    for(int p=0; p < formats.size(); p++) {
      SyslogFormater fmt = formats.get(p);
      try {
        scanner.findInLine(fmt.regexPattern);
        res = scanner.match();
      } catch (IllegalStateException e) {
        // Ignore and move on ..
        continue;
      }
      for (int grp=1; grp <= res.groupCount(); grp++) {
View Full Code Here

        } catch (NullPointerException e) {
            // Expected
        }
        String result = s.findInLine(Pattern.compile("^"));
        assertEquals("", result);
        MatchResult matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(0, matchResult.end());

        result = s.findInLine(Pattern.compile("$"));
        assertEquals("", result);
View Full Code Here

        assertEquals(0, matchResult.start());
        assertEquals(0, matchResult.end());

        result = s.findInLine(Pattern.compile("$"));
        assertEquals("", result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(0, matchResult.end());

        /*
         * When we use the operation of findInLine(Pattern), the match region
View Full Code Here

        assertNull(result);

        s = new Scanner("abcd1234test\n");
        result = s.findInLine(Pattern.compile("\\p{Lower}+"));
        assertEquals("abcd", result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Digit}{5}"));
        assertNull(result);
View Full Code Here

        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Digit}{5}"));
        assertNull(result);
        try {
            matchResult = s.match();
            fail("Should throw IllegalStateException");
        } catch (IllegalStateException e) {
            // expected
        }
        assertEquals(0, matchResult.start());
View Full Code Here

        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        result = s.findInLine(Pattern.compile("\\p{Lower}+"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(8, matchResult.start());
        assertEquals(12, matchResult.end());

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

        stringBuilder.append(chars);
        stringBuilder.append("1234");
        s = new Scanner(stringBuilder.toString());
        result = s.findInLine(Pattern.compile("\\p{Digit}+"));
        assertEquals("1234", result);
        matchResult = s.match();
        assertEquals(2048, matchResult.start());
        assertEquals(2052, matchResult.end());

        s = new Scanner("test");
        s.close();
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.