thufir

fred fred

Sep 17th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. package telnet;
  2.  
  3. import java.util.logging.Logger;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. public class Alias {
  8.  
  9.     private static final Logger log = Logger.getLogger(Alias.class.getName());
  10.  
  11.     public Alias() {
  12.     }
  13.  
  14.     public String parse(String line) throws StringIndexOutOfBoundsException {
  15.         char c = line.charAt(0);
  16.         String s = String.valueOf(c);
  17.         if ("/".equals(s)) {
  18.             line = getAlias(line);
  19.         }
  20.         return line;
  21.     }
  22.  
  23.     private String getAlias(String line) {
  24. //        String sentence = line.subSequence(1, line.length()).toString();
  25.  
  26.         Pattern pattern = Pattern.compile("(\\w+)");  //(\w+)\.
  27.         Matcher matcher = pattern.matcher(line);
  28.         String action = null;
  29.         String target = null;
  30.         while (matcher.find()) {
  31.             action = matcher.group(0);
  32.             target = matcher.group(1);
  33.         }
  34.        
  35.         log.info(action+target);
  36.  
  37.         return "";
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment