Examples of Regexp


Examples of com.google.gwt.regexp.shared.RegExp

  * Generates a {@link URLPattern} from a {@link Page#path()}
  * @param urlTemplate The {@link Page#path()}
  * @return A {@link URLPattern} used to match URLs
  */
  public static URLPattern generatePattern(String urlTemplate) {
    RegExp regex = RegExp.compile(URLPattern.paramRegex, "g");
    List<String> paramList = new ArrayList<String>();

    MatchResult mr = null;
    StringBuilder sb = new StringBuilder();

    // Ensure matching at beginning of line
    sb.append("^");

    int endOfPreviousPattern = 0;
    int startOfNextPattern = 0;

    while ((mr = regex.exec(urlTemplate)) != null) {
      addParamName(paramList, mr);
      startOfNextPattern = mr.getIndex();
     
      // Append any string literal that may occur in the URL path
      // before the next parameter.
      sb.append(urlTemplate, endOfPreviousPattern, startOfNextPattern);
     
      // Append regex for matching the parameter value
      sb.append(URLPattern.urlSafe);
     
      endOfPreviousPattern = regex.getLastIndex();
    }

    // Append any remaining trailing string literals
    sb.append(urlTemplate, endOfPreviousPattern, urlTemplate.length());

View Full Code Here

Examples of com.google.gwt.regexp.shared.RegExp

   * @throws IllegalStateException
   *           If a path parameter is missing from the given state map.
   * @return The constructed URL path without the application context.
   */
  public String printURL(ImmutableMultimap<String, String> state) {
    RegExp re = RegExp.compile(paramRegex, "g");
    String url = this.urlTemplate;
   
    MatchResult mr;

    while ((mr = re.exec(this.urlTemplate)) != null) {
      String toReplace = mr.getGroup(0);
      String key = mr.getGroup(1);
      if (toReplace.contains(key)) {
        url = url.replace(toReplace, state.get(key).iterator().next());
      }
View Full Code Here

Examples of com.sun.msv.datatype.xsd.regex.RegExp

            re = new RegularExpression(exp,"X");
        } catch ( com.sun.msv.datatype.regexp.ParseException e ) {
            throw new ParseException(e.getMessage(),e.getLocation());
        }

        return new RegExp() {
            public boolean matches(String text) {
                return re.matches(text);
            }
        };
    }
View Full Code Here

Examples of dk.brics.automaton.RegExp

public class CompiledAutomaton implements RegexImpl {

    private RunAutomaton runauto = null;
   
    public CompiledAutomaton( String rhsPattern ) {
        RegExp regexpr = new dk.brics.automaton.RegExp(rhsPattern);
        Automaton auto = regexpr.toAutomaton();
        this.runauto = new RunAutomaton(auto, true);
    }
View Full Code Here

Examples of eas.math.fundamentalAlgorithms.regExp.RegExp

   
    /**
     * TODO: This does not work yet!
     */
    public RegExp generateRegExp() {
        RegExp regExp;

        HashMap<StatePairOM, RegExp> table = new HashMap<StatePairOM, RegExp>();
        ArrayList<String> reachable = new ArrayList<String>(this.getAllReachableStates());
       
        for (int k = 0; k < reachable.size(); k++) {
            for (int i = 0; i < reachable.size(); i++) {
                for (int j = 0; j < reachable.size(); j++) {
                    StatePairOM keyij = new StatePairOM(reachable.get(i), reachable.get(j));
                    if (k == 0) { // First entry.
                        for (Transition t : this.getTransitions(reachable.get(i), reachable.get(j))) {
                            this.addExpressionToTableEntry(new RegExpCharacter(t.getLabel()), table, keyij);
                        }
                        if (reachable.get(i).equals(reachable.get(j))) {
                            this.addExpressionToTableEntry(new RegExpLambda(), table, keyij);
                        }
                    } else {
                        StatePairOM keyik = new StatePairOM(reachable.get(i), reachable.get(k));
                        StatePairOM keykk = new StatePairOM(reachable.get(k), reachable.get(k));
                        StatePairOM keykj = new StatePairOM(reachable.get(k), reachable.get(j));
                       
                        RegExp rik = table.get(keyik);
                        RegExp rkk = table.get(keykk);
                        RegExp rkj = table.get(keykj);
                        RegExp newreg;
                       
                        if (rkk == null) {
                            rkk = new RegExpEmpty();
                        }
                       
View Full Code Here

Examples of fr.norsys.mapper.console.mapping.RegExp

      Attribute attribute = new Attribute(a.getKey());
      attribute.setAttributeLDAP(a.getVal());
      attribute.setDefaultValue(a.getVal());
      attribute.setInputOutput(ConsoleCst.INPUT_ATTRIBUTE_TYPE);
      for (Iterator it2 = regexps.iterator(); it2.hasNext();) {
        RegExp re = (RegExp) it2.next();
        if (a.getKey().equals(re.getKey())) {
          attribute.setRule(re.getValue());
          attribute.setIgnoreNull(re.getIgnoreNull());
        }
      }
      r.addAttribute(attribute);
    }
  }
View Full Code Here

Examples of hampi.constraints.Regexp

public class BoundingTests extends TestCase{
  public void testMultiCharTerminals() throws Exception{
    Grammar g = new Parser(GrammarTests.DIR + "test_multiCharTerminal.txt").parse();
    GrammarStringBounder gsb = new GrammarStringBounder();
    Regexp boundedRegexp = gsb.getBoundedRegexp(g, "program", 3, false);
    System.out.println(boundedRegexp);
    assertTrue(!boundedRegexp.matches("AB__"));
    assertTrue(boundedRegexp.matches("AB_"));
  }
View Full Code Here

Examples of jflex.RegExp

    assertTrue(RegExp.revString("blah").equals("halb"));
  }

  public void testCharClass() {
    Macros m = new Macros();   
    RegExp e1 = new RegExp1(CCLASS, new Interval('a','z'));
    RegExp e2 = new RegExp1(CHAR, 'Z');
    RegExp e3 = new RegExp1(CCLASS, new Interval('0','9'));
    m.insert("macro", e3);
    RegExp s = new RegExp1(STAR, e1);
    RegExp u = new RegExp1(MACROUSE, "macro");   
    RegExp b = new RegExp2(BAR, e2, u);
    assertTrue(e1.isCharClass(m));
    assertTrue(e2.isCharClass(m));
    assertTrue(b.isCharClass(m));
    assertTrue(!s.isCharClass(m));
    assertTrue(u.isCharClass(m));
  }
View Full Code Here

Examples of net.percederberg.grammatica.parser.re.RegExp

         *
         * @throws Exception if the regular expression contained
         *             invalid syntax
         */
        public GrammaticaRE(String regex) throws Exception {
            regExp = new RegExp(regex, ignoreCase);
        }
View Full Code Here

Examples of org.apache.lucene.util.automaton.RegExp

   * @param term regular expression.
   * @param flags optional RegExp features from {@link RegExp}
   * @param provider custom AutomatonProvider for named automata
   */
  public NodeRegexpQuery(final Term term, final int flags, final AutomatonProvider provider) {
    super(term, new RegExp(term.text(), flags).toAutomaton(provider));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.