All pastes #258318 Raw Edit

Mine

public text v1 · immutable
#258318 ·published 2006-11-26 11:54 UTC
rendered paste body
private String doRegex(String Regex, String source, int group, boolean ignoreCase){
        System.out.println("Using pattern: "+Regex);
    String result = "";
    //First of all we will create a single-line-doc:
        
        source = source.replace("\n", "");
        source = source.replace("\r\n", "");
        
        Pattern p = null;
        Matcher m = null;
        
        try {
            if(ignoreCase){
          p = Pattern.compile(Regex, p.CASE_INSENSITIVE);
          System.out.println("Ignoring case");
            } else { p = Pattern.compile(Regex); }
          m = p.matcher(source);
          if(m.find(group) == false){ System.out.println("Nothing found."); }
          result = m.group(group);   
          
          return(transformHTML(result)); 
        }catch(IllegalStateException ex){
           result = "";
           System.out.println("Regex-Exeption catched.");
        }
        return(result);
    }