com.caucho.quercus.lib.regexp
Class JavaRegexpModule

java.lang.Object
  extended by com.caucho.quercus.module.AbstractQuercusModule
      extended by com.caucho.quercus.lib.regexp.JavaRegexpModule
All Implemented Interfaces:
QuercusModule

public class JavaRegexpModule
extends AbstractQuercusModule


Field Summary
static int PCRE_UTF8
           
static int PREG_GREP_INVERT
           
static int PREG_OFFSET_CAPTURE
           
static int PREG_PATTERN_ORDER
           
static boolean[] PREG_QUOTE
           
static int PREG_REPLACE_EVAL
           
static int PREG_SET_ORDER
           
static int PREG_SPLIT_DELIM_CAPTURE
           
static int PREG_SPLIT_NO_EMPTY
           
static int PREG_SPLIT_OFFSET_CAPTURE
           
 
Fields inherited from class com.caucho.quercus.module.AbstractQuercusModule
PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER
 
Constructor Summary
JavaRegexpModule()
           
 
Method Summary
static Value ereg_replace(Env env, Value pattern, Value replacement, StringValue subject)
           
static Value ereg(Env env, Value pattern, StringValue string, Value regsV)
          Returns the index of the first match.
static Value eregi_replace(Env env, Value pattern, Value replacement, StringValue subject)
          Replaces values using regexps
static Value eregi(Env env, Value pattern, StringValue string, Value regsV)
          Returns the index of the first match.
protected static Value eregImpl(Env env, Value rawPattern, StringValue string, Value regsV, int flags)
          Returns the index of the first match.
static Value eregReplaceImpl(Env env, Value pattern, Value replacement, StringValue subject, boolean isCaseInsensitive)
          Replaces values using regexps
 java.lang.String[] getLoadedExtensions()
          Returns the extensions loaded by the module.
static Value preg_grep(Env env, StringValue patternString, ArrayValue input, int flag)
          Returns an array of all the values that matched the given pattern if the flag no flag is passed.
static Value preg_match_all(Env env, StringValue regexp, StringValue subject, Value matchRef, int flags, int offset)
          Returns the index of the first match.
static Value preg_match(Env env, StringValue regexp, StringValue subject, Value matchRef, int flags, int offset)
          Returns the index of the first match.
static StringValue preg_quote(StringValue string, StringValue delim)
          Quotes regexp values
static Value preg_replace_callback(Env env, Value pattern, Callback fun, Value subject, long limit, Value count)
          Loops through subject if subject is array of strings
static Value preg_replace(Env env, Value pattern, Value replacement, Value subject, long limit, Value count)
          Loops through subject if subject is array of strings
static Value preg_split(Env env, StringValue patternString, StringValue string, long limit, int flags)
          Returns array of substrings or of arrays ([0] => substring [1] => offset) if PREG_SPLIT_OFFSET_CAPTURE is set
static Value pregMatchAllPatternOrder(Env env, com.caucho.quercus.lib.regexp.JavaRegexpModule.PCREPattern pcrePattern, StringValue subject, ArrayValue matches, int flags, int offset)
          Returns the index of the first match.
static Value split(Env env, StringValue patternString, StringValue string, long limit)
          Returns the index of the first match.
static ArrayValue spliti(Env env, StringValue patternString, StringValue string, long limit)
          Returns an array of strings produces from splitting the passed string around the provided pattern.
static StringValue sql_regcase(StringValue string)
          Makes a regexp for a case-insensitive match.
 
Methods inherited from class com.caucho.quercus.module.AbstractQuercusModule
getConstMap, getIniDefinitions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREG_REPLACE_EVAL

public static final int PREG_REPLACE_EVAL
See Also:
Constant Field Values

PCRE_UTF8

public static final int PCRE_UTF8
See Also:
Constant Field Values

PREG_PATTERN_ORDER

public static final int PREG_PATTERN_ORDER
See Also:
Constant Field Values

PREG_SET_ORDER

public static final int PREG_SET_ORDER
See Also:
Constant Field Values

PREG_OFFSET_CAPTURE

public static final int PREG_OFFSET_CAPTURE
See Also:
Constant Field Values

PREG_SPLIT_NO_EMPTY

public static final int PREG_SPLIT_NO_EMPTY
See Also:
Constant Field Values

PREG_SPLIT_DELIM_CAPTURE

public static final int PREG_SPLIT_DELIM_CAPTURE
See Also:
Constant Field Values

PREG_SPLIT_OFFSET_CAPTURE

public static final int PREG_SPLIT_OFFSET_CAPTURE
See Also:
Constant Field Values

PREG_GREP_INVERT

public static final int PREG_GREP_INVERT
See Also:
Constant Field Values

PREG_QUOTE

public static final boolean[] PREG_QUOTE
Constructor Detail

JavaRegexpModule

public JavaRegexpModule()
Method Detail

getLoadedExtensions

public java.lang.String[] getLoadedExtensions()
Description copied from class: AbstractQuercusModule
Returns the extensions loaded by the module.

Specified by:
getLoadedExtensions in interface QuercusModule
Overrides:
getLoadedExtensions in class AbstractQuercusModule

ereg

public static Value ereg(Env env,
                         Value pattern,
                         StringValue string,
                         Value regsV)
Returns the index of the first match.

Parameters:
env - the calling environment

eregi

public static Value eregi(Env env,
                          Value pattern,
                          StringValue string,
                          Value regsV)
Returns the index of the first match.

Parameters:
env - the calling environment

eregImpl

protected static Value eregImpl(Env env,
                                Value rawPattern,
                                StringValue string,
                                Value regsV,
                                int flags)
Returns the index of the first match.

Parameters:
env - the calling environment

preg_match

public static Value preg_match(Env env,
                               StringValue regexp,
                               StringValue subject,
                               Value matchRef,
                               int flags,
                               int offset)
Returns the index of the first match. php/151u The array that preg_match (PHP 5) returns does not have trailing unmatched groups. Therefore, an unmatched group should not be added to the array unless a matched group appears after it. A couple applications like Gallery2 expect this behavior in order to function correctly. Only preg_match and preg_match_all(PREG_SET_ORDER) exhibits this odd behavior.

Parameters:
env - the calling environment

preg_match_all

public static Value preg_match_all(Env env,
                                   StringValue regexp,
                                   StringValue subject,
                                   Value matchRef,
                                   int flags,
                                   int offset)
Returns the index of the first match.

Parameters:
env - the calling environment

pregMatchAllPatternOrder

public static Value pregMatchAllPatternOrder(Env env,
                                             com.caucho.quercus.lib.regexp.JavaRegexpModule.PCREPattern pcrePattern,
                                             StringValue subject,
                                             ArrayValue matches,
                                             int flags,
                                             int offset)
Returns the index of the first match.

Parameters:
env - the calling environment

preg_quote

public static StringValue preg_quote(StringValue string,
                                     StringValue delim)
Quotes regexp values


preg_replace

public static Value preg_replace(Env env,
                                 Value pattern,
                                 Value replacement,
                                 Value subject,
                                 long limit,
                                 Value count)
Loops through subject if subject is array of strings

Parameters:
env -
pattern - string or array
replacement - string or array
subject - string or array
limit -
count -
Returns:

ereg_replace

public static Value ereg_replace(Env env,
                                 Value pattern,
                                 Value replacement,
                                 StringValue subject)

eregi_replace

public static Value eregi_replace(Env env,
                                  Value pattern,
                                  Value replacement,
                                  StringValue subject)
Replaces values using regexps


eregReplaceImpl

public static Value eregReplaceImpl(Env env,
                                    Value pattern,
                                    Value replacement,
                                    StringValue subject,
                                    boolean isCaseInsensitive)
Replaces values using regexps


preg_replace_callback

public static Value preg_replace_callback(Env env,
                                          Value pattern,
                                          Callback fun,
                                          Value subject,
                                          long limit,
                                          Value count)
Loops through subject if subject is array of strings

Parameters:
env -
pattern -
fun -
subject -
limit -
count -
Returns:

preg_split

public static Value preg_split(Env env,
                               StringValue patternString,
                               StringValue string,
                               long limit,
                               int flags)
Returns array of substrings or of arrays ([0] => substring [1] => offset) if PREG_SPLIT_OFFSET_CAPTURE is set

Parameters:
env - the calling environment

sql_regcase

public static StringValue sql_regcase(StringValue string)
Makes a regexp for a case-insensitive match.


split

public static Value split(Env env,
                          StringValue patternString,
                          StringValue string,
                          long limit)
Returns the index of the first match.

Parameters:
env - the calling environment

preg_grep

public static Value preg_grep(Env env,
                              StringValue patternString,
                              ArrayValue input,
                              int flag)
Returns an array of all the values that matched the given pattern if the flag no flag is passed. Otherwise it will return an array of all the values that did not match.

Parameters:
patternString - the pattern
input - the array to check the pattern against
flag - 0 for matching and 1 for elements that do not match
Returns:
an array of either matching elements are non-matching elements

spliti

public static ArrayValue spliti(Env env,
                                StringValue patternString,
                                StringValue string,
                                long limit)
Returns an array of strings produces from splitting the passed string around the provided pattern. The pattern is case insensitive.

Parameters:
patternString - the pattern
string - the string to split
limit - if specified, the maximum number of elements in the array
Returns:
an array of strings split around the pattern string