package com.mars.test.java;

import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by USER on 2016/12/13.
 */
@Slf4j
public class TestString {

    @Test
    public void testRegexp() {
        String test1 = "123412";
        String test2 = "asdgfjsadfjla";
        String test3 = "asdgfjs2342342";
        String test4 = "asdgfjs2342342:";

        log.info("test1.match = " + test1.matches("\\w+"));
        log.info("test2.match = " + test2.matches("\\w+"));
        log.info("test3.match = " + test3.matches("\\w+"));
        log.info("test4.match = " + test4.matches("\\w+"));

        String test5 = "123";
        String test6 = "123123412";
        String test7 = "asd12";
        String test8 = "asd;[;";
        String test9 = "asdgfjs2342342";

        log.info("test5.match = " + test5.matches("\\w{2,6}"));
        log.info("test6.match = " + test6.matches("\\w{2,6}"));
        log.info("test7.match = " + test7.matches("\\w{2,6}"));
        log.info("test8.match = " + test8.matches("\\w{2,6}"));
        log.info("test9.match = " + test9.matches("\\w{2,6}"));
        Assert.assertTrue(test5.matches("\\w{2,6}"));
        Assert.assertFalse(test6.matches("\\w{2,6}"));
        Assert.assertTrue(test7.matches("\\w{2,6}"));
        Assert.assertFalse(test8.matches("\\w{2,6}"));
        Assert.assertFalse(test9.matches("\\w{2,6}"));
    }


}

@@ -781,26 +781,26 @@
  %22asdgfj
-s2
+_-
 342342%22;
 %0A%0A      
@@ -791,16 +791,48 @@
 342342%22;
+%0A        String test10 = %22as-_%22;
 %0A%0A      
@@ -1137,32 +1137,98 @@
 s(%22%5C%5Cw%7B2,6%7D%22));%0A
+        log.info(%22test10.match = %22 + test10.matches(%22%5C%5Cw%7B2,6%7D%22));%0A
         Assert.a
@@ -1456,25 +1456,26 @@
 rtFalse(test
-9
+10
 .matches(%22%5C%5C

add String regexp sample