(String[] args)
| 6 | |
| 7 | public class Resetting { |
| 8 | public static void |
| 9 | main(String[] args) throws Exception { |
| 10 | Matcher m = Pattern.compile("[frb][aiu][gx]") |
| 11 | .matcher("fix the rug with bags"); |
| 12 | while(m.find()) |
| 13 | System.out.print(m.group() + " "); |
| 14 | System.out.println(); |
| 15 | m.reset("fix the rig with rags"); |
| 16 | while(m.find()) |
| 17 | System.out.print(m.group() + " "); |
| 18 | } |
| 19 | } |
| 20 | /* Output: |
| 21 | fix rug bag |