Java Doc for RegularExpression.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » xpath » regex » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » xerces 2_9_1 » org.apache.xerces.impl.xpath.regex 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.xerces.impl.xpath.regex.RegularExpression

RegularExpression
public class RegularExpression implements java.io.Serializable(Code)
A regular expression matching engine using Non-deterministic Finite Automaton (NFA). This engine does not conform to the POSIX regular expression.

How to use

A. Standard way
 RegularExpression re = new RegularExpression(regex);
 if (re.matches(text)) { ... }
 
B. Capturing groups
 RegularExpression re = new RegularExpression(regex);
 Match match = new Match();
 if (re.matches(text, match)) {
 ... // You can refer captured texts with methods of the Match class.
 }
 

Case-insensitive matching

 RegularExpression re = new RegularExpression(regex, "i");
 if (re.matches(text) >= 0) { ...}
 

Options

You can specify options to RegularExpression(regex, options) or setPattern(regex, options). This options parameter consists of the following characters.

"i"
This option indicates case-insensitive matching.
"m"
^ and $ consider the EOL characters within the text.
"s"
. matches any one character.
"u"
Redefines \d \D \w \W \s \S \b \B \< \> as becoming to Unicode.
"w"
By this option, \b \B \< \> are processed with the method of 'Unicode Regular Expression Guidelines' Revision 4. When "w" and "u" are specified at the same time, \b \B \< \> are processed for the "w" option.
","
The parser treats a comma in a character class as a range separator. [a,b] matches a or , or b without this option. [a,b] matches a or b with this option.
"X"
By this option, the engine confoms to XML Schema: Regular Expression. The match() method does not do subsring matching but entire string matching.

Syntax

Differences from the Perl 5 regular expression

  • There is 6-digit hexadecimal character representation (\u005cvHHHHHH.)
  • Supports subtraction, union, and intersection operations for character classes.
  • Not supported: \ooo (Octal character representations), \G, \C, \lc, \u005c uc, \L, \U, \E, \Q, \N{name}, (?{code}), (??{code})

Meta characters are `. * + ? { [ ( ) | \ ^ $'.

  • Character
    . (A period)
    Matches any one character except the following characters.
    LINE FEED (U+000A), CARRIAGE RETURN (U+000D), PARAGRAPH SEPARATOR (U+2029), LINE SEPARATOR (U+2028)
    This expression matches one code point in Unicode. It can match a pair of surrogates.
    When the "s" option is specified, it matches any character including the above four characters.
    \e \f \n \r \t
    Matches ESCAPE (U+001B), FORM FEED (U+000C), LINE FEED (U+000A), CARRIAGE RETURN (U+000D), HORIZONTAL TABULATION (U+0009)
    \cC
    Matches a control character. The C must be one of '@', 'A'-'Z', '[', '\u005c', ']', '^', '_'. It matches a control character of which the character code is less than the character code of the C by 0x0040.
    For example, a \cJ matches a LINE FEED (U+000A), and a \c[ matches an ESCAPE (U+001B).
    a non-meta character
    Matches the character.
    \ + a meta character
    Matches the meta character.
    \u005cxHH \u005cx{HHHH}
    Matches a character of which code point is HH (Hexadecimal) in Unicode. You can write just 2 digits for \u005cxHH, and variable length digits for \u005cx{HHHH}.
    \u005cvHHHHHH
    Matches a character of which code point is HHHHHH (Hexadecimal) in Unicode.
    \g
    Matches a grapheme.
    It is equivalent to (?[\p{ASSIGNED}]-[\p{M}\p{C}])?(?:\p{M}|[\x{094D}\x{09CD}\x{0A4D}\x{0ACD}\x{0B3D}\x{0BCD}\x{0C4D}\x{0CCD}\x{0D4D}\x{0E3A}\x{0F84}]\p{L}|[\x{1160}-\x{11A7}]|[\x{11A8}-\x{11FF}]|[\x{FF9E}\x{FF9F}])*
    \X
    Matches a combining character sequence. It is equivalent to (?:\PM\pM*)
  • Character class
    + *
    [R1R2...Rn] (without "," option) + *
    [R1,R2,...,Rn] (with "," option)
    Positive character class. It matches a character in ranges.
    Rn:
    • A character (including \e \f \n \r \t \u005cxHH \u005cx{HHHH} \u005cvHHHHHH)

      This range matches the character.

    • C1-C2

      This range matches a character which has a code point that is >= C1's code point and <= C2's code point. + *

    • A POSIX character class: [:alpha:] [:alnum:] [:ascii:] [:cntrl:] [:digit:] [:graph:] [:lower:] [:print:] [:punct:] [:space:] [:upper:] [:xdigit:], + * and negative POSIX character classes in Perl like [:^alpha:]

      ...

    • \d \D \s \S \w \W \p{name} \P{name}

      These expressions specifies the same ranges as the following expressions.

    Enumerated ranges are merged (union operation). [a-ec-z] is equivalent to [a-z]

    [^R1R2...Rn] (without a "," option)
    [^R1,R2,...,Rn] (with a "," option)
    Negative character class. It matches a character not in ranges.
    (?[ranges]op[ranges]op[ranges] ... ) (op is - or + or &.)
    Subtraction or union or intersection for character classes.
    For exmaple, (?[A-Z]-[CF]) is equivalent to [A-BD-EG-Z], and (?[0x00-0x7f]-[K]&[\p{Lu}]) is equivalent to [A-JL-Z].
    The result of this operations is a positive character class even if an expression includes any negative character classes. You have to take care on this in case-insensitive matching. For instance, (?[^b]) is equivalent to [\x00-ac-\x{10ffff}], which is equivalent to [^b] in case-sensitive matching. But, in case-insensitive matching, (?[^b]) matches any character because it includes 'B' and 'B' matches 'b' though [^b] is processed as [^Bb].
    [R1R2...-[RnRn+1...]] (with an "X" option)
    Character class subtraction for the XML Schema. You can use this syntax when you specify an "X" option.
    \d
    Equivalent to [0-9].
    When a "u" option is set, it is equivalent to \p{Nd}.
    \D
    Equivalent to [^0-9]
    When a "u" option is set, it is equivalent to \P{Nd}.
    \s
    Equivalent to [ \f\n\r\t]
    When a "u" option is set, it is equivalent to [ \f\n\r\t\p{Z}].
    \S
    Equivalent to [^ \f\n\r\t]
    When a "u" option is set, it is equivalent to [^ \f\n\r\t\p{Z}].
    \w
    Equivalent to [a-zA-Z0-9_]
    When a "u" option is set, it is equivalent to [\p{Lu}\p{Ll}\p{Lo}\p{Nd}_].
    \W
    Equivalent to [^a-zA-Z0-9_]
    When a "u" option is set, it is equivalent to [^\p{Lu}\p{Ll}\p{Lo}\p{Nd}_].
    \p{name}
    Matches one character in the specified General Category (the second field in UnicodeData.txt) or the specified Block. The following names are available:
    Unicode General Categories:
    L, M, N, Z, C, P, S, Lu, Ll, Lt, Lm, Lo, Mn, Me, Mc, Nd, Nl, No, Zs, Zl, Zp, Cc, Cf, Cn, Co, Cs, Pd, Ps, Pe, Pc, Po, Sm, Sc, Sk, So,
    (Currently the Cn category includes U+10000-U+10FFFF characters)
    Unicode Blocks:
    Basic Latin, Latin-1 Supplement, Latin Extended-A, Latin Extended-B, IPA Extensions, Spacing Modifier Letters, Combining Diacritical Marks, Greek, Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Thai, Lao, Tibetan, Georgian, Hangul Jamo, Latin Extended Additional, Greek Extended, General Punctuation, Superscripts and Subscripts, Currency Symbols, Combining Marks for Symbols, Letterlike Symbols, Number Forms, Arrows, Mathematical Operators, Miscellaneous Technical, Control Pictures, Optical Character Recognition, Enclosed Alphanumerics, Box Drawing, Block Elements, Geometric Shapes, Miscellaneous Symbols, Dingbats, CJK Symbols and Punctuation, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, Enclosed CJK Letters and Months, CJK Compatibility, CJK Unified Ideographs, Hangul Syllables, High Surrogates, High Private Use Surrogates, Low Surrogates, Private Use, CJK Compatibility Ideographs, Alphabetic Presentation Forms, Arabic Presentation Forms-A, Combining Half Marks, CJK Compatibility Forms, Small Form Variants, Arabic Presentation Forms-B, Specials, Halfwidth and Fullwidth Forms
    Others:
    ALL (Equivalent to [\u005cu0000-\u005cv10FFFF])
    ASSGINED (\p{ASSIGNED} is equivalent to \P{Cn})
    UNASSGINED (\p{UNASSIGNED} is equivalent to \p{Cn})
    \P{name}
    Matches one character not in the specified General Category or the specified Block.
  • Selection and Quantifier
    X|Y
    ...
    X*
    Matches 0 or more X.
    X+
    Matches 1 or more X.
    X?
    Matches 0 or 1 X.
    X{number}
    Matches number times.
    X{min,}
    ...
    X{min,max}
    ...
    X*?
    X+?
    X??
    X{min,}?
    X{min,max}?
    Non-greedy matching.
  • Grouping, Capturing, and Back-reference
    (?:X)
    Grouping. "foo+" matches "foo" or "foooo". If you want it matches "foofoo" or "foofoofoo", you have to write "(?:foo)+".
    (X)
    Grouping with capturing. It make a group and applications can know where in target text a group matched with methods of a Match instance after matches(String,Match). The 0th group means whole of this regular expression. The Nth gorup is the inside of the Nth left parenthesis.

    For instance, a regular expression is " *([^<:]*) +<([^>]*)> *" and target text is "From: TAMURA Kent <kent@trl.ibm.co.jp>":

    • Match.getCapturedText(0): " TAMURA Kent <kent@trl.ibm.co.jp>"
    • Match.getCapturedText(1): "TAMURA Kent"
    • Match.getCapturedText(2): "kent@trl.ibm.co.jp"
    \1 \2 \3 \4 \5 \6 \7 \8 \9
    (?>X)
    Independent expression group. ................
    (?options:X)
    (?options-options2:X)
    ............................
    The options or the options2 consists of 'i' 'm' 's' 'w'. Note that it can not contain 'u'.
    (?options)
    (?options-options2)
    ......
    These expressions must be at the beginning of a group.
  • Anchor
    \A
    Matches the beginnig of the text.
    \Z
    Matches the end of the text, or before an EOL character at the end of the text, or CARRIAGE RETURN + LINE FEED at the end of the text.
    \z
    Matches the end of the text.
    ^
    Matches the beginning of the text. It is equivalent to \A.
    When a "m" option is set, it matches the beginning of the text, or after one of EOL characters ( LINE FEED (U+000A), CARRIAGE RETURN (U+000D), LINE SEPARATOR (U+2028), PARAGRAPH SEPARATOR (U+2029).)
    $
    Matches the end of the text, or before an EOL character at the end of the text, or CARRIAGE RETURN + LINE FEED at the end of the text.
    When a "m" option is set, it matches the end of the text, or before an EOL character.
    \b
    Matches word boundary. (See a "w" option)
    \B
    Matches non word boundary. (See a "w" option)
    \<
    Matches the beginning of a word. (See a "w" option)
    \>
    Matches the end of a word. (See a "w" option)
  • Lookahead and lookbehind
    (?=X)
    Lookahead.
    (?!X)
    Negative lookahead.
    (?<=X)
    Lookbehind.
    (Note for text capturing......)
    (?<!X)
    Negative lookbehind.
  • Misc.
    (?(condition)yes-pattern|no-pattern),
    (?(condition)yes-pattern)
    ......
    (?#comment)
    Comment. A comment string consists of characters except ')'. You can not write comments in character classes and before quantifiers.

BNF for the regular expression

 regex ::= ('(?' options ')')? term ('|' term)*
 term ::= factor+
 factor ::= anchors | atom (('*' | '+' | '?' | minmax ) '?'? )?
 | '(?#' [^)]* ')'
 minmax ::= '{' ([0-9]+ | [0-9]+ ',' | ',' [0-9]+ | [0-9]+ ',' [0-9]+) '}'
 atom ::= char | '.' | char-class | '(' regex ')' | '(?:' regex ')' | '\' [0-9]
 | '\w' | '\W' | '\d' | '\D' | '\s' | '\S' | category-block | '\X'
 | '(?>' regex ')' | '(?' options ':' regex ')'
 | '(?' ('(' [0-9] ')' | '(' anchors ')' | looks) term ('|' term)? ')'
 options ::= [imsw]* ('-' [imsw]+)?
 anchors ::= '^' | '$' | '\A' | '\Z' | '\z' | '\b' | '\B' | '\<' | '\>'
 looks ::= '(?=' regex ')'  | '(?!' regex ')'
 | '(?<=' regex ')' | '(?<!' regex ')'
 char ::= '\\' | '\' [efnrtv] | '\c' [@-_] | code-point | character-1
 category-block ::= '\' [pP] category-symbol-1
 | ('\p{' | '\P{') (category-symbol | block-name
 | other-properties) '}'
 category-symbol-1 ::= 'L' | 'M' | 'N' | 'Z' | 'C' | 'P' | 'S'
 category-symbol ::= category-symbol-1 | 'Lu' | 'Ll' | 'Lt' | 'Lm' | Lo'
 | 'Mn' | 'Me' | 'Mc' | 'Nd' | 'Nl' | 'No'
 | 'Zs' | 'Zl' | 'Zp' | 'Cc' | 'Cf' | 'Cn' | 'Co' | 'Cs'
 | 'Pd' | 'Ps' | 'Pe' | 'Pc' | 'Po'
 | 'Sm' | 'Sc' | 'Sk' | 'So'
 block-name ::= (See above)
 other-properties ::= 'ALL' | 'ASSIGNED' | 'UNASSIGNED'
 character-1 ::= (any character except meta-characters)
 char-class ::= '[' ranges ']'
 | '(?[' ranges ']' ([-+&] '[' ranges ']')? ')'
 ranges ::= '^'? (range ','?)+
 range ::= '\d' | '\w' | '\s' | '\D' | '\W' | '\S' | category-block
 | range-char | range-char '-' range-char
 range-char ::= '\[' | '\]' | '\\' | '\' [,-efnrtv] | code-point | character-2
 code-point ::= '\x' hex-char hex-char
 | '\x{' hex-char+ '}'
                | '\v' hex-char hex-char hex-char hex-char hex-char hex-char
 hex-char ::= [0-9a-fA-F]
 character-2 ::= (any character except \[]-,)
 

TODO



author:
   TAMURA Kent <kent@trl.ibm.co.jp>
version:
   $Id: RegularExpression.java 446721 2006-09-15 20:35:34Z mrglavas $

Inner Class :final static class Context

Field Summary
final static  intCARRIAGE_RETURN
    
final static  booleanDEBUG
    
final static  intEXTENDED_COMMENT
    
final static  intIGNORE_CASE
    
final static  intLINE_FEED
    
final static  intLINE_SEPARATOR
    
final static  intMULTIPLE_LINES
    
final static  intPARAGRAPH_SEPARATOR
    
final static  intPROHIBIT_FIXED_STRING_OPTIMIZATION
    
final static  intPROHIBIT_HEAD_CHARACTER_OPTIMIZATION
    
final static  intSINGLE_LINE
    
final static  intSPECIAL_COMMA
     ",".
final static  intUNICODE_WORD_BOUNDARY
     An option.
final static  intUSE_UNICODE_CATEGORY
     This option redefines \d \D \w \W \s \S.
final static  intXMLSCHEMA_MODE
     "X".
transient  Contextcontext
    
transient  RangeTokenfirstChar
    
transient  StringfixedString
    
transient  booleanfixedStringOnly
    
transient  intfixedStringOptions
    
transient  BMPatternfixedStringTable
    
 booleanhasBackReferences
    
transient  intminlength
    
 intnofparen
     The number of parenthesis in the regular expression.
transient  intnumberOfClosures
    
transient  Opoperations
    
 intoptions
    
 Stringregex
     A regular expression.
 Tokentokentree
     Internal representation of the regular expression.

Constructor Summary
public  RegularExpression(String regex)
     Creates a new RegularExpression instance.
public  RegularExpression(String regex, String options)
     Creates a new RegularExpression instance with options.
 RegularExpression(String regex, Token tok, int parens, boolean hasBackReferences, int options)
    

Method Summary
public  booleanequals(Object obj)
     Return true if patterns are the same and the options are equivalent.
 booleanequals(String pattern, int options)
    
public  intgetNumberOfGroups()
     Return the number of regular expression groups.
public  StringgetOptions()
     Returns a option string.
public  StringgetPattern()
    
public  inthashCode()
    
public  booleanmatches(char[] target)
     Checks whether the target text contains this pattern or not.
public  booleanmatches(char[] target, int start, int end)
     Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
public  booleanmatches(char[] target, Match match)
     Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result.
public  booleanmatches(char[] target, int start, int end, Match match)
     Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
Parameters:
  match - A Match instance for storing matching result.
public  booleanmatches(String target)
     Checks whether the target text contains this pattern or not.
public  booleanmatches(String target, int start, int end)
     Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
public  booleanmatches(String target, Match match)
     Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result.
public  booleanmatches(String target, int start, int end, Match match)
     Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
Parameters:
  match - A Match instance for storing matching result.
public  booleanmatches(CharacterIterator target)
     Checks whether the target text contains this pattern or not.
public  booleanmatches(CharacterIterator target, Match match)
     Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result.
 voidprepare()
     Prepares for matching.
public  voidsetPattern(String newPattern)
    
public  voidsetPattern(String newPattern, String options)
    
public  StringtoString()
     Represents this instence in String.

Field Detail
CARRIAGE_RETURN
final static int CARRIAGE_RETURN(Code)



DEBUG
final static boolean DEBUG(Code)



EXTENDED_COMMENT
final static int EXTENDED_COMMENT(Code)
"x"



IGNORE_CASE
final static int IGNORE_CASE(Code)
"i"



LINE_FEED
final static int LINE_FEED(Code)



LINE_SEPARATOR
final static int LINE_SEPARATOR(Code)



MULTIPLE_LINES
final static int MULTIPLE_LINES(Code)
"m"



PARAGRAPH_SEPARATOR
final static int PARAGRAPH_SEPARATOR(Code)



PROHIBIT_FIXED_STRING_OPTIMIZATION
final static int PROHIBIT_FIXED_STRING_OPTIMIZATION(Code)
"F"



PROHIBIT_HEAD_CHARACTER_OPTIMIZATION
final static int PROHIBIT_HEAD_CHARACTER_OPTIMIZATION(Code)
"H"



SINGLE_LINE
final static int SINGLE_LINE(Code)
"s"



SPECIAL_COMMA
final static int SPECIAL_COMMA(Code)
",".



UNICODE_WORD_BOUNDARY
final static int UNICODE_WORD_BOUNDARY(Code)
An option. This enables to process locale-independent word boundary for \b \B \< \>.

By default, the engine considers a position between a word character (\w) and a non word character is a word boundary.

By this option, the engine checks word boundaries with the method of 'Unicode Regular Expression Guidelines' Revision 4.
See Also:   RegularExpression.RegularExpression(java.lang.String,int)
See Also:   RegularExpression.setPattern(java.lang.String,int)




USE_UNICODE_CATEGORY
final static int USE_UNICODE_CATEGORY(Code)
This option redefines \d \D \w \W \s \S.
See Also:   RegularExpression.RegularExpression(java.lang.String,int)
See Also:   RegularExpression.setPattern(java.lang.String,int)
See Also:   RegularExpression.UNICODE_WORD_BOUNDARY



XMLSCHEMA_MODE
final static int XMLSCHEMA_MODE(Code)
"X". XML Schema mode.



context
transient Context context(Code)



firstChar
transient RangeToken firstChar(Code)



fixedString
transient String fixedString(Code)



fixedStringOnly
transient boolean fixedStringOnly(Code)



fixedStringOptions
transient int fixedStringOptions(Code)



fixedStringTable
transient BMPattern fixedStringTable(Code)



hasBackReferences
boolean hasBackReferences(Code)



minlength
transient int minlength(Code)



nofparen
int nofparen(Code)
The number of parenthesis in the regular expression.



numberOfClosures
transient int numberOfClosures(Code)



operations
transient Op operations(Code)



options
int options(Code)



regex
String regex(Code)
A regular expression.



tokentree
Token tokentree(Code)
Internal representation of the regular expression.




Constructor Detail
RegularExpression
public RegularExpression(String regex) throws ParseException(Code)
Creates a new RegularExpression instance.
Parameters:
  regex - A regular expression
exception:
  org.apache.xerces.utils.regex.ParseException - regex is not conforming to the syntax.



RegularExpression
public RegularExpression(String regex, String options) throws ParseException(Code)
Creates a new RegularExpression instance with options.
Parameters:
  regex - A regular expression
Parameters:
  options - A String consisted of "i" "m" "s" "u" "w" "," "X"
exception:
  org.apache.xerces.utils.regex.ParseException - regex is not conforming to the syntax.



RegularExpression
RegularExpression(String regex, Token tok, int parens, boolean hasBackReferences, int options)(Code)




Method Detail
equals
public boolean equals(Object obj)(Code)
Return true if patterns are the same and the options are equivalent.



equals
boolean equals(String pattern, int options)(Code)



getNumberOfGroups
public int getNumberOfGroups()(Code)
Return the number of regular expression groups. This method returns 1 when the regular expression has no capturing-parenthesis.



getOptions
public String getOptions()(Code)
Returns a option string. The order of letters in it may be different from a string specified in a constructor or setPattern().
See Also:   RegularExpression.RegularExpression(java.lang.String,java.lang.String)
See Also:   RegularExpression.setPattern(java.lang.String,java.lang.String)



getPattern
public String getPattern()(Code)



hashCode
public int hashCode()(Code)



matches
public boolean matches(char[] target)(Code)
Checks whether the target text contains this pattern or not. true if the target is matched to this regular expression.



matches
public boolean matches(char[] target, int start, int end)(Code)
Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range. true if the target is matched to this regular expression.



matches
public boolean matches(char[] target, Match match)(Code)
Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result. Offset of the start position in target; or -1 if not match.



matches
public boolean matches(char[] target, int start, int end, Match match)(Code)
Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
Parameters:
  match - A Match instance for storing matching result. Offset of the start position in target; or -1 if not match.



matches
public boolean matches(String target)(Code)
Checks whether the target text contains this pattern or not. true if the target is matched to this regular expression.



matches
public boolean matches(String target, int start, int end)(Code)
Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range. true if the target is matched to this regular expression.



matches
public boolean matches(String target, Match match)(Code)
Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result. Offset of the start position in target; or -1 if not match.



matches
public boolean matches(String target, int start, int end, Match match)(Code)
Checks whether the target text contains this pattern in specified range or not.
Parameters:
  start - Start offset of the range.
Parameters:
  end - End offset +1 of the range.
Parameters:
  match - A Match instance for storing matching result. Offset of the start position in target; or -1 if not match.



matches
public boolean matches(CharacterIterator target)(Code)
Checks whether the target text contains this pattern or not. true if the target is matched to this regular expression.



matches
public boolean matches(CharacterIterator target, Match match)(Code)
Checks whether the target text contains this pattern or not.
Parameters:
  match - A Match instance for storing matching result. Offset of the start position in target; or -1 if not match.



prepare
void prepare()(Code)
Prepares for matching. This method is called just before starting matching.



setPattern
public void setPattern(String newPattern) throws ParseException(Code)



setPattern
public void setPattern(String newPattern, String options) throws ParseException(Code)



toString
public String toString()(Code)
Represents this instence in String.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.