Java regular expression regex to extract characters

Directly on the code:

 1 @Test
 2 
 3     public void contextLoads() {
 4 
 5         /*String str="this is (Tom) and \"Eric\", this is \"Bruce lee\", he is a chinese, name is \"李小龙\"。";
 6 
 7         Pattern p= Pattern.compile("\"(.*?)\"");
 8 
 9         Matcher m=p.matcher(str);
10 
11         while(m.find()){
12 
13             System.out.println(m.group());
14 
15         }*/
16 
17  
18 
19  
20 
21         /*String str="this is [Tom] and , he is a [chinese], name [is]。";
22 is  
23 is          Matcher of Pattern.compile MAT = ( "(<= \\ [) (S \\ +) (= \\?])?") Matcher (STR);.
 24  
25          the while (mat.find ()) {
 26 is  
27              System.out.println (mat.group ());
 28  
29          } * / 
30  
31 is   
32  
33 is   
34 is  
35          String FILETEXT = "// [Zhang name] 25 minutes @ [Li floret] 43 minutes @ [Wang force] 100 " ;
 36  
37 [          the Pattern of Pattern.compile P = (."? \\ [(*) \\] "); // regular expression, and taken = | string between, and not including = | 
38 is  
39          Matcher m = p.matcher (FILETEXT);
 40  
41 is          the while (m.find ()) {
 42 is 
43 is              System.out.println (m.group (0)); // m.group (. 1) not including the two characters 
44 is  
45          }
 46 is  
47      }

 

Guess you like

Origin www.cnblogs.com/smartisn/p/12276032.html