|
-
Dec 4th, 2004, 04:31 PM
#1
Thread Starter
Dazed Member
Greedy,Reluctant,Possessive Quantifers?
Anyone know what the similarities or differences are between these quantifers? Under the docs the descriptions are all the same.
Greedy quantifiers
X? X, once or not at all
X* X, zero or more times
X+ X, one or more times
X{n} X, exactly n times
X{n,} X, at least n times
X{n,m} X, at least n but not more than m times
Reluctant quantifiers
X?? X, once or not at all
X*? X, zero or more times
X+? X, one or more times
X{n}? X, exactly n times
X{n,}? X, at least n times
X{n,m}? X, at least n but not more than m times
Possessive quantifiers
X?+ X, once or not at all
X*+ X, zero or more times
X++ X, one or more times
X{n}+ X, exactly n times
X{n,}+ X, at least n times
X{n,m}+ X, at least n but not more than m times
Also how are these quantifers used? I made a simple test program using the greedy,reluctant,possessive quantifiers(X, once or not at all) quantifers
but i don't understand the output.
Code:
import java.util.*;
public class X{
public static void main(String[] args){
String data = new String("mxpxr");
Scanner s = new Scanner(data);
// s.useDelimiter("x"); // returns mpr
// s.useDelimiter("x?"); // returns mpr{greedy quantifer}
// s.useDelimiter("x??"); // returns mxpxr{reluctant quantifer}
// s.useDelimiter("x?+"); // returns mpr{possessive quantifer}
while(s.hasNext()){
System.out.println(s.next());
}
}
}
Last edited by Dilenger4; Dec 23rd, 2004 at 01:24 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|