Class: Java::java::util::regex::Pattern

Inherits:
Object
  • Object
show all
Defined in:
core/src/main/ruby/jruby/java/java_ext/java.util.regex.rb

Overview

Note:

Only explicit (or customized) Ruby methods are listed, instances will have all of their Java methods available.

java.util.regex.Pattern enhanced to act similar to Ruby's `Regexp`.

See Also:

Instance Method Summary (collapse)

Instance Method Details

- (true, false) ===(str)

Case equality for Java patterns.

Returns:

  • (true, false)


19
20
21
22
# File 'core/src/main/ruby/jruby/java/java_ext/java.util.regex.rb', line 19

def ===(str)
  # stub implemented in org.jruby.javasupport.ext.JavaUtilRegex.java
  # matcher(str).find
end

- (Integer?) =~(str)

Matches this pattern against provided string.

Returns:

  • (Integer, nil)

    start (index) of the match if any



11
12
13
14
15
# File 'core/src/main/ruby/jruby/java/java_ext/java.util.regex.rb', line 11

def =~(str)
  # stub implemented in org.jruby.javasupport.ext.JavaUtilRegex.java
  # m = matcher(str)
  # m.find ? m.start : nil
end

- (true, false) casefold?

Returns the value of the case-insensitive flag.

Returns:

  • (true, false)

Since:

  • 9.1



38
39
40
# File 'core/src/main/ruby/jruby/java/java_ext/java.util.regex.rb', line 38

def casefold?
  # stub implemented in org.jruby.javasupport.ext.JavaUtilRegex.java
end

- (Java::java::util::regex::Matcher?) match(str)

Returns a `Matcher` object describing the match against the string (or nil if there was no match).

Examples:

pattern = java.util.regex.Pattern.compile('[a-f]')
matcher = pattern.match('abcdef') # java.util.regex.Matcher[pattern=[a-f] region=0,6 lastmatch=a]

Returns:



29
30
31
32
33
# File 'core/src/main/ruby/jruby/java/java_ext/java.util.regex.rb', line 29

def match(str)
  # stub implemented in org.jruby.javasupport.ext.JavaUtilRegex.java
  # m = matcher(str)
  # m.find ? m : nil
end