/*
  Suppose you have a lot of files in a directory that contain words
  Exercisei_j, where i and j are digits. Write a program that pads a 0 before
  i if i is a single digit and 0 before j if j is a single digit. For example,
  the word Exercise2_1 in a file will be replaced by Exercise02_01. Use the
  following command to run our program. Use the following command to run your
  program.

  java E12_27 *
*/

import java.io.File;

public class E12_27 {
  public static void main(String[] args) {
    for (String s: args) {
      File file = new File(s);
      if (s.matches(".*Exercise\\d_\\d.*")) {
        StringBuilder sb = new StringBuilder(s);
        int index = sb.indexOf("Exercise");
        sb.insert((index + 8), "0");
        sb.insert((index + 11), "0");
        File newName = new File(sb.toString());
        file.renameTo(newName);
      }
    }
  }
}

@@ -548,24 +548,71 @@
 ew File(s);%0A
+      StringBuilder sb = new StringBuilder(s);%0A
       if (s.
@@ -620,18 +620,16 @@
 atches(%22
-.*
 Exercise
@@ -639,10 +639,8 @@
 _%5C%5Cd
-.*
 %22)) 
@@ -653,92 +653,104 @@
     
-StringBuilder sb = new StringBuilder(s);%0A        int index = sb.indexOf(%22Exercise%22);
+sb.insert(8, %220%22);%0A        sb.insert(11, %220%22);%0A      %7D else if (s.matches(%22Exercise%5C%5Cd_%5C%5Cd+%22)) %7B
 %0A   
@@ -768,27 +768,17 @@
 ert(
-(index + 8)
+8
 , %220%22);%0A
     
@@ -765,32 +765,82 @@
 insert(8, %220%22);%0A
+      %7D else if (s.matches(%22Exercise%5C%5Cd+_%5C%5Cd%22)) %7B%0A
         sb.inser
@@ -845,20 +845,10 @@
 ert(
-(index + 
 11
-)
 , %220
@@ -849,24 +849,30 @@
 11, %220%22);%0A  
+    %7D%0A
       File n
@@ -911,18 +911,16 @@
 ;%0A      
-  
 file.ren
@@ -935,24 +935,16 @@
 wName);%0A
-      %7D%0A
     %7D%0A  

Modify solution to fit the exercise specifications more closely