Optimizing regular expressions in Java - Java World
Popularity Report
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
URL Tag Cloud
Bookmark History
Saved by 2 people (0 private), first by anonymouse user on 2008-07-28
- Pistos on 2008-08-21 - Tags optimizing , regular , expressions , regex , regexp , performance , java
- Benxshen on 2008-07-28 - Tags no_tag
Public Sticky notes
If you will use a regular expression more than once in your program, be sure to compile the pattern using
Pattern.compile() instead of the more direct Pattern.matches().
Highlighted by benxshen
Also remember that you can re-use the
Matcher object for different input strings by calling the method reset().
Highlighted by benxshen
If you don't really need to capture the text inside a
group, always use non-capturing groups. For example, use "
(?:X)" instead of "(X)".
Highlighted by benxshen


Public Comment