MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 1 as of 2014-08-04 22:00:31
  • Java

Java

Regular expressions

   1 /*
   2 javac TesteRe.java 
   3 java -cp . TesteRe 
   4 */
   5 import java.util.regex.Pattern;
   6 import java.util.regex.Matcher;
   7 
   8 public class TesteRe{
   9 
  10     public static void main(String args[]){ 
  11         String values[]={"aa12.txt","a123sss.txt","bs11bb.txt","123aaaa.sql","a12.txt","aaaa12","20ghj","6657"};
  12         Pattern a = Pattern.compile("^(\\D+)(\\d+)(\\D+)$");
  13         Pattern b = Pattern.compile("^(\\d+)(\\D+)$");
  14         Pattern c = Pattern.compile("^(\\D+)(\\d+)$");
  15         Pattern d = Pattern.compile("^(\\d+)$");
  16 
  17         for(String item:values){
  18             Matcher ma = a.matcher(item);
  19             Matcher mb = b.matcher(item);
  20             Matcher mc = c.matcher(item);
  21             Matcher md = d.matcher(item);
  22 
  23            if(ma.matches()){ 
  24                int val = Integer.parseInt(ma.group(2)) + 1;
  25                System.out.println(String.format("A: mv %s %s%d%s",item,ma.group(1),val,ma.group(3)  ) );
  26            }
  27 
  28            if(mb.matches()){ 
  29                int val = Integer.parseInt(mb.group(1)) + 1;
  30                System.out.println(String.format("B: mv %s %d%s",item, val , mb.group(2)  ) );
  31            }
  32 
  33            if(mc.matches()){ 
  34                int val = Integer.parseInt(mc.group(2)) + 1;
  35                System.out.println(String.format("C: mv %s %s%d",item,mc.group(1),val   ) );
  36            }
  37 
  38            if(md.matches()){ 
  39                int val = Integer.parseInt(md.group(1)) + 1;
  40                System.out.println(String.format("D: mv %s %d",item, val  ) );
  41            }
  42 
  43         }
  44     }
  45 }
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01