java string to a predetermined character segmentation, segmentation and character segmentation remove content

. 1  Import the java.util.regex *. ; 
 2  
. 3  
. 4  public  class A { 
 . 5  public  static  void main (String [] args) { 
 . 6   String X = "43535 + 50.34 / 98% * 108.47-3876.9 7√ =" ;
 . 7   of Pattern.compile P = the Pattern ( "[% * = √ / + -]");           // set of characters 
. 8 String [] = R & lt p.split (X);          // by character set is divided 
. 9 Matcher m p.matcher = (X);          // to find the set of characters assigned to m 
10  the while (m.find ()) System.out.println ( "operator:" + m.group ());      // Print all operators 
. 11  for( Int I = 0; I <r.length; I ++) System.out.println (R & lt [I]);}}  // print out all the parameters 
12 is  
13 is  

 

Guess you like

Origin www.cnblogs.com/dehao/p/11428560.html