2017-03-29 3 views

답변

2

String url1 = "http://shop.lenovo.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/cart.workflow:ShowCart?shopping-menu-s..."; 

    String subS1 = "shop.lenovo.com/"; 
    Pattern p1 = Pattern.compile(subS1); 
    Matcher match1 = p1.matcher(url1); 

    String subS2 = "en_US/cart"; 
    Pattern p2 = Pattern.compile(subS2); 
    Matcher match2 = p2.matcher(url1); 

    if (match1.find() && match2.find()) 
    { 
     // Whatever you like 
    } 
+1

나는 json에서 regex와 url을 얻고, 매번 다른 정규식을 얻는다. 특정 솔루션을 설명했습니다. 방금 find() 함수를 사용하기 시작했습니다. 감사! –