Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm inclined to agree with Rex M, although your second requirement for numerical constraints complicates things. Unless you only allowed very basic constraints, I'm not aware of a way to succinctly express that in a regular expression. If there is such a way, please disregard the rest of my answer and follow the other suggestions here. :)</p> <p>You might want to consider a parser generator - things like the classic lex and yacc. I'm not really familiar with the Java choices, but here's a list:</p> <p><a href="http://java-source.net/open-source/parser-generators" rel="nofollow noreferrer">http://java-source.net/open-source/parser-generators</a></p> <p>If you're not familiar, the standard approach would be to first create a <a href="http://en.wikipedia.org/wiki/Lexical_analysis" rel="nofollow noreferrer">lexer</a> that turns your strings into tokens. Then you would pass those tokens onto a parser that applies your grammar to them and spits out some kind of result.</p> <p>In your case, I envision the parser resulting in a combination of a regular expression and additional conditions. For your numerical constraint example, it might give you the regular expression <code>\/cal/long/3/4/143:(\d+)\</code> and a constraint to apply to the first grouping (the <code>\d+</code> portion) that requires that the number lie between 100 and 1100. You'd then apply the RE to your strings for candidates, and apply the constraint to those candidates to find your matches.</p> <p>It's a pretty complicated approach, so hopefully there's a simpler way. I hope that gives you some ideas, at least.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload