java.util.regex question: "OR" order matters?
807606Feb 6 2007 — edited Feb 6 2007I have a large regex of several tokens or'd together. Here's an example: ^(CH|CHAP)
When I run it against my input string, I want it to match against the largest possible token in the or'd list. So here are examples:
"Input String" | Match
"CHA" | CH
"CHAPTER" | CHAP
Is there a way to do this without ordering the list of tokens that gets or'd together? Currently, it looks like it's using the first match that fits (in this example, "CHAPTER" would match on CH first and ignore CHAP).