String getReplacement() {
        StringBuilder s = new StringBuilder();
        
        if (replacement == null) {
            
            return getMatchReplacement();
            
        } else {
        
            for (int i = 0; i < replacement.length(); i++) {
                char c = replacement.charAt(i);
                
                if (c == '$' && i < replacement.length() - 1) {
                    c = replacement.charAt(++i);

                    switch (c) {
                    case '$':
                        s.append(getMatchReplacement());
                        break;
                    case '<':
                        s.append(owner.prefix());
                        break;
                    case '>':
                        s.append(owner.suffix());
                        break;
                    default:
                        if (i < 2 || replacement.charAt(i - 2) != '(') {
                            s.append(owner.getGroup(replacement.substring(i, i + 1)));
                        } else {
                            String name = replacement.substring(i).replaceFirst("\\).*", "");
                            s.deleteCharAt(s.length() - 1);
                            s.append(owner.getGroup(name));
                            i += name.length();
                        } // else
                        break;
                    } // switch
                    continue;
                } // if
                
                s.append(c);
            } // for
            
        } // else

        return s.toString();
    } //getReplacement