2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
9 import java.util.Hashtable;
\r
11 /** Matches any number of instances of sub Pattern
\r
12 this was the hardest method to write. It implements
\r
13 '+', '*', '?', "{0,10}", "{5,}", "{5}", etc.
\r
14 @see pat.Multi_stage2
\r
17 class Multi extends PatternSub {
\r
19 public patInt minChars() { return a.mul(p.countMinChars()); }
\r
20 public patInt maxChars() { return b.mul(p.countMaxChars()); }
\r
23 public boolean matchFewest = false;
\r
25 @param a The fewest number of times the sub pattern can match.
\r
26 @param b The maximum number of times the sub pattern can match.
\r
27 @param p The sub pattern.
\r
31 public Multi(patInt a,patInt b,Pattern p) throws RegSyntax {
\r
35 st2 = new Multi_stage2(a,b,p);
\r
39 public String toString() {
\r
40 st2.matchFewest = matchFewest;
\r
41 return st2.toString();
\r
43 public int matchInternal(int pos,Pthings pt) {
\r
45 st2 = new Multi_stage2(a,b,p);
\r
46 } catch(RegSyntax r__) {}
\r
47 st2.matchFewest = matchFewest;
\r
49 return st2.matchInternal(pos,pt);
\r
51 public Pattern clone1(Hashtable h) {
\r
53 Multi m = new Multi(a,b,((Pattern)p).clone(h));
\r
54 m.matchFewest = matchFewest;
\r
56 } catch(RegSyntax rs) {
\r