Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

just put index.html back for now until figure out how to do this corr…

…eclty

*	deleted:    README.md
*	new file:   index.html
  • Loading branch information...
commit d53dd6e413800f00540f9fbe7dbd47ca5bb053f9 1 parent 8246fcf
raw authored
Showing with 242 additions and 306 deletions.
  1. +0 −306 doc/README.md
  2. +242 −0 doc/index.html
View
306 doc/README.md
@@ -1,306 +0,0 @@
-
-************ lliibb__mmyyssqqlluuddff__pprreegg ************
-********** IInnttrroodduuccttiioonn **********
-lib_mysqludf_preg is a library of mysql UDFs (user-defined-functions) that
-provide access to the PCRE (perl compatible-regular-expressions) library for
-pattern matching. The PCRE library is a set of functions that implement regular
-expression pattern matching using the same syntax and semantics as Perl 5. This
-syntax can often handle more complex expressions and capturing than standard
-regular expression implementations. For more information about PCRE, please
-see: _h_t_t_p_:_/_/_w_w_w_._p_c_r_e_._o_r_g_/
-
-lib_mysqludf_preg is a useful performance optimization for those applications
-that are already performing these regular expression matches in a high level
-language (ie. PHP) on the client side. It is also helpful when there is a need
-to capture a parenthesized subexpression from a regular expression, or simply
-as a slight performance boost over the builtin RLIKE/REGEXP functions.
-********** IInnssttaallllaattiioonn **********
-lib_mysqludf_preg is distributed as a source package. (Binaries are available
-for the Windows version.) The instructions below provide some information about
-how to configure and compile the library. Please consult the INSTALL file
-included with the source package for more details. If installing from source
-for Windows please consult the doc/INSTALL.win file.
-******** FFrroomm SSoouurrccee ********
-****** PPrreerreeqquuiissiitteess ******
-These UDFs require that the libpcre headers and library are installed. For
-debian/ubuntu type systems, installing libpcre3-dev should be sufficient. (aapptt--
-ggeett iinnssttaallll lliibbppccrree33--ddeevv).
-****** CCoommppiillaattiioonn ******
-Most users should be able to simply type: ..//ccoonnffiigguurree ;; mmaakkee iinnssttaallll
-If mysql is an unusual place, you might need to add --with-mysql=<mysql
-directory>/bin/mysql_config.
-Similarly, if licpcre is in an unusual place, --with-pcre can be added.
-Example (for osx using fink): ./configure --with-pcre=/sw --with-mysql=/sw/bin/
-mysql_config
-Also, version 1.1 changes the way NULLs are handled. To restore the legacy NULL
-handling, add --enable-legacy-nulls to the configure line
-Provided the library has been installled into a directory that mysql server
-already has in its LD_LIBRARY_PATH, installation of the functions should be as
-easy as typing: mmaakkee iinnssttaallllddbb. Any problems encountered are likely related to
-the server's environment and the installation directory. If no problems are
-encountered, type mmaakkee tteesstt to perform some basic tests.
-******** WWiinnddoowwss BBiinnaarriieess ********
-There is a zip file, downloadable from this site, that contains the necessary
-dll files to run this UDF on windows. One of these dll files is the UDF,
-itself, and the other required dll file is the PCRE library. These files both
-need to be installed in directories where the MySQL server can find them. For
-the 5.0 series of mysql server, this should be the bin directory directly under
-the Mysql\ Server installation. For the 5.1 MySQL servers this is the directory
-as specified by the 'plugin_dir' MySQL variable. After copying the files and
-restarting the server, the 3rd file in the archive can be used to create the
-functions.
-For more information, please consult the doc/INSTALL.windows file in the source
-package.
-
-********** FFuunnccttiioonnss **********
-lib_mysqludf_preg provides the following functions that interface with the PCRE
-library.
- * _p_r_e_g___c_a_p_t_u_r_e capture a parenthesized subexpression from a PCRE pattern
- * _p_r_e_g___c_h_e_c_k check if a string is a valid perl-compatible regular
- expression
- * _p_r_e_g___p_o_s_i_t_i_o_n get position of the of a regular expression capture group
- in a string
- * _p_r_e_g___r_e_p_l_a_c_e perform regular expression search & replace using PCRE.
- * _p_r_e_g___r_l_i_k_e test if a string matches a perl-compatible regular expression
- * _l_i_b___m_y_s_q_l_u_d_f___p_r_e_g___i_n_f_o get information about the installed
- lib_mysqludf_preg library
-
-********** pprreegg__ccaappttuurree **********
-capture a parenthesized subexpression from a PCRE pattern
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION preg_capture RETURNS STRING SONAME
- 'lib_mysqludf_preg.so';
- SSyynnooppssiiss
- PREG_CAPTURE( pattern , subject [, group] [, occurence] )
- PPaarraammeetteerrss::
- ppaatttteerrnn - is a string that is a perl compatible regular expression as
- documented at: _h_t_t_p_:_/_/_u_s_._p_h_p_._n_e_t_/_m_a_n_u_a_l_/_e_n_/_r_e_f_._p_c_r_e_._p_h_p This
- expression passed to this function should have delimiters and
- can contain the standard perl modifiers after the ending
- delimiter.
- ssuubbjjeecctt -is the data to perform the match & capture on
- ggrroouupp - is the capture group that should be returned. This can be a
- numeric capture group or a named capture group. Numeric
- groups should be passed in as integers while named groups
- should be strings. If not speficied, this defaults to 0,
- which will capture the entire matching regular expression.
- ooccccuurreennccee - which match of the regex to perform capture on. This is
- useful for subjects that have multiple matches of the
- pattern. If not speficied, this defaults to 1, which will
- capture the requested group, from the first matching
- occurence of the pattern.
- RReettuurrnnss::
- - string that was captured - if there was a match and the desired capture
- group is valid
- - string that is the entire portion of subject which matches the pattern
- - if 0 is passed in as the group and pattern matches subject
- - NULL - if pattern does not match the subject or group is not a valid
- capture group for the given pattern and subject.
-preg_capture is a udf that captures parenthesized sub-expressions from a pcre
-pattern.
- EExxaammpplleess::
-SELECT PREG_CAPTURE('/(.*?)(fox)/' , 'the quick brown fox' ,2 );
-YYiieellddss::
-+----------------------------------------------------------+
-| PREG_CAPTURE('/(.*?)(fox)/' , 'the quick brown fox' ,2 ) |
-+----------------------------------------------------------+
-| fox |
-+----------------------------------------------------------+
-SELECT PREG_CAPTURE( '/"([^"]+)"/' , 'the "quick" brown fox "jumped" over the
-"lazy" dog' , 1,2 );
-+------------------------------------------------------------------------------
---------------+
-| PREG_CAPTURE( '/"([^"]+)"/' , 'the "quick" brown fox "jumped" over the "lazy"
-dog' , 1,2 ) |
-+------------------------------------------------------------------------------
---------------+
-| jumped
-|
-+------------------------------------------------------------------------------
---------------+
-SELECT PREG_CAPTURE( '/b[^\s]+/' , 'the quick brown fox jumped over' )
-YYiieellddss::
-+------------------------------------------------------------------+
-| PREG_CAPTURE( '/b[^\\s]+/' , 'the quick brown fox jumped over' ) |
-+------------------------------------------------------------------+
-| brown |
-+------------------------------------------------------------------+
- NNoottee::
- Remember to add a backslash to escape patterns that use \ notation
-
-********** pprreegg__cchheecckk **********
-Test if a perl-compatible regular expression is valid
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION preg_check RETURNS INTEGER SONAME 'lib_mysqludf_preg.so';
- SSyynnooppssiiss
- PREG_CHECK( pattern )
- PPaarraammeetteerrss::
- ppaatttteerrnn - is a string that might be a perl compatible regular
- expression as documented at: _h_t_t_p_:_/_/_u_s_._p_h_p_._n_e_t_/_m_a_n_u_a_l_/_e_n_/
- _r_e_f_._p_c_r_e_._p_h_p
- RReettuurrnnss::
- 1 - the pcre is valid
- 0 - the pcre is NULL, empty, or a bad regex
-preg_check is a udf that tests if whether or not the given perl compatible
-regular expression is valid. This is a useful companion to the other functions
-in the lib_mysqludf_pref library in that those functions all return errors (and
-stop processing) when empty, NULL, or incorrect regular expressions are passed
-in to them. If pcre patterns are stored in rows of a database and it is not
-confirmed that the patterns are valid, PCRE_CHECK is useful either as a filter
-used in conjunction with those calls or as a separate query to help cleanup the
-database before using those other functions.
- EExxaammpplleess::
-SELECT PREG_CHECK('/The quick brown fox/i' );
-YYiieellddss::
- +---------------------------------------------------------------+
- | PREG_CHECK('/The quick brown fox/i' ) |
- +---------------------------------------------------------------+
- | 1 |
- +---------------------------------------------------------------+
-SELECT * from patterns WHERE PREG_CHECK( pattern );
-Yields: all of the rows containing valid pcre's.
-
-********** pprreegg__ppoossiittiioonn **********
-get position of the of a regular expression capture group in a string
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION preg_position RETURNS INTEGER SONAME
- 'lib_mysqludf_preg.so';
- SSyynnooppssiiss
- PREG_POSITION( pattern , subject [, group] [, occurence] )
- PPaarraammeetteerrss::
- ppaatttteerrnn - is a string that is a perl compatible regular expression as
- documented at: _h_t_t_p_:_/_/_u_s_._p_h_p_._n_e_t_/_m_a_n_u_a_l_/_e_n_/_r_e_f_._p_c_r_e_._p_h_p This
- expression passed to this function should have delimiters and
- can contain the standard perl modifiers after the ending
- delimiter.
- ssuubbjjeecctt -is the data to perform the match & position capture on
- ggrroouupp - the capture group whose position that should be returned.
- This can be a numeric capture group or a named capture group.
- Numeric groups should be passed in as integers, while named
- groups should be strings. 0 should be used to request to
- position of the entire matching expression. This parameter
- defaults to 0.
- ooccccuurreennccee - which match of the regex to perform capture on. This is
- useful for subjects that have multiple matches of the
- pattern. This parameter defaults to 1.
- RReettuurrnnss::
- - integer position of the string that was captured - if there was a match
- and the desired capture group and occurence is valid
- - NULL if pattern does not match the subject or group is not a valid
- capture group or the occurence is larger than the number of matches for
- the given pattern and subject.
-preg_position is a udf that captures the position of matching regular
-expression from a pcre pattern. It can be useful when strings need to be split
-by a pcre pattern or if the location of the pattern within the string is needed
-for some other reason.
- EExxaammpplleess::
-SELECT PREG_POSITION('/(.*?)(fox)/' , 'the quick brown fox' ,2 );
-YYiieellddss::
-+-----------------------------------------------------------+
-| PREG_POSITION('/(.*?)(fox)/' , 'the quick brown fox' ,2 ) |
-+-----------------------------------------------------------+
-| 17 |
-+-----------------------------------------------------------+
-SELECT PREG_POSITION('/"[^"]+"/' , '"quick","brown","fox" "jumped"',0,4)
-YYiieellddss::
-+-------------------------------------------------------------------+
-| PREG_POSITION('/"[^"]+"/' , '"quick","brown","fox" "jumped"',0,4) |
-+-------------------------------------------------------------------+
-| 23 |
-+-------------------------------------------------------------------+
- NNoottee::
- Remember to add a backslash to escape patterns that use \ notation. The
- returned position starts at 1 for the first character, as is standard for
- MySQL string functions.
-
-********** pprreegg__rreeppllaaccee **********
-performs regular expression search & replace using PCRE.
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION preg_replace RETURNS STRING SONAME
- 'lib_mysqludf_preg.so';
- SSyynnooppssiiss
- PREG_REPLACE( pattern , replacement , subject [ , limit ] )
- PPaarraammeetteerrss::
- ppaatttteerrnn - is a string that is a perl compatible regular expression
- as documented at: _h_t_t_p_:_/_/_u_s_._p_h_p_._n_e_t_/_m_a_n_u_a_l_/_e_n_/_r_e_f_._p_c_r_e_._p_h_p
- This expression passed to this function should have
- delimiters and can contain the standard perl modifiers
- after the ending delimiter.
- rreeppllaacceemmeenntt - is the string to use as the replacement. This string may
- contain capture group references such as \1. You can also
- use $1 for these in a similar fashion as in PHP.
- ssuubbjjeecctt -is the data to perform the match & replace on
- lliimmiitt - optional number that is the maximum replacements to
- perform. Use -1 (or leave empty) for no limit.
- RReettuurrnnss::
- - string - 'subject' with the instances of pattern replaced
- - string - the same as passed in if there were no matches
-preg_replace is a udf that performs a regular expression search and replace on
-a given piece of data using a PCRE as the replacement pattern. If limit is not
-speficied or is -1, preg_replace works on all of the ocurrences of the pattern
-in the subject data. Otherwise, preg_replace will only replace the first
-<limit> occurences.
- EExxaammpplleess::
-SELECT PREG_REPLACE('/(.*?)(fox)/' , '$1dog' , 'the quick brown fox' );
-YYiieellddss::
-+-----------------------------------------------------------------+
-| PREG_REPLACE('/(.*?)(fox)/' , '$1dog' , 'the quick brown fox' ) |
-+-----------------------------------------------------------------+
-| the quick brown dog |
-+-----------------------------------------------------------------+
-SELECT PREG_REPLACE('/\s\s/+', ' ' , products.title FROM products;
-Yields: The product names with all of the extra whitespace removed
- NNoottee::
- Remember to add a backslash to escape patterns that use \ notation. Also,
- using $ notation makes things a little clearer when using backreferences
- in the replacement.
-
-********** pprreegg__rrlliikkee **********
-Test if a string matches a perl-compatible regular expression
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION preg_rlike RETURNS INTEGER SONAME 'lib_mysqludf_preg.so';
- SSyynnooppssiiss
- PREG_RLIKE( pattern , subject )
- PPaarraammeetteerrss::
- ppaatttteerrnn - is a string that is a perl compatible regular expression as
- documented at: _h_t_t_p_:_/_/_u_s_._p_h_p_._n_e_t_/_m_a_n_u_a_l_/_e_n_/_r_e_f_._p_c_r_e_._p_h_p This
- expression passed to this function should have delimiters and
- can contain the standard perl modifiers after the ending
- delimiter.
- ssuubbjjeecctt - is the data to perform the test on.
- RReettuurrnnss::
- 1 - a match was found
- 0 - no match
-preg_rlike is a udf that tests if whether or not the given perl compatible
-regular expression matches the given data.
- EExxaammpplleess::
-SELECT PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' );
-YYiieellddss::
- +---------------------------------------------------------------+
- | PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' ) |
- +---------------------------------------------------------------+
- | 1 |
- +---------------------------------------------------------------+
-SELECT * from products WHERE PREG_RLIKE( '/organic/i' , products.title )
-Yields: all of the products with 'organic' in their titles
-
-********** lliibb__mmyyssqqlluuddff__pprreegg__iinnffoo **********
-Return version information for lib_mysqludf_preg package
- FFuunnccttiioonn IInnssttaallllaattiioonn
- CREATE FUNCTION lib_mysqludf_preg_info RETURNS STRING SONAME
- 'lib_mysqludf_preg.so' ;
- SSyynnooppssiiss
- LIB_MYSQLUDF_PREG_INFO()
- RReettuurrnnss::
- string - version information for the lib_mysqludf_preg package
- EExxaammpplleess::
- SELECT LIB_MYSQLUDF_PREG_INFO();
-YYiieellddss::
-+--------------------------+
-| LIB_MYSQLUDF_PREG_INFO() |
-+--------------------------+
-| lib_mysqludf_preg 0.6.1 |
-+--------------------------+
-===============================================================================
- Generated on Sat Mar 23 18:24:07 2013 for lib_mysqludf_preg by
- _[_d_o_x_y_g_e_n_] 1.5.9
View
242 doc/index.html
@@ -0,0 +1,242 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>lib_mysqludf_preg: lib_mysqludf_preg</title>
+<link href="tabs.css" rel="stylesheet" type="text/css">
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="contents">
+<h1>lib_mysqludf_preg</h1>
+<p>
+<h2><a class="anchor" name="intro_sec">
+Introduction</a></h2>
+lib_mysqludf_preg is a library of mysql UDFs (user-defined-functions) that provide access to the PCRE (perl compatible-regular-expressions) library for pattern matching. The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. This syntax can often handle more complex expressions and capturing than standard regular expression implementations. For more information about PCRE, please see: <a href="http://www.pcre.org/">http://www.pcre.org/</a><p>
+<br>
+ lib_mysqludf_preg is a useful performance optimization for those applications that are already performing these regular expression matches in a high level language (ie. PHP) on the client side. It is also helpful when there is a need to capture a parenthesized subexpression from a regular expression, or simply as a slight performance boost over the builtin RLIKE/REGEXP functions.<h2><a class="anchor" name="Installation">
+Installation</a></h2>
+lib_mysqludf_preg is distributed as a source package. (Binaries are available for the Windows version.) The instructions below provide some information about how to configure and compile the library. Please consult the INSTALL file included with the source package for more details. If installing from source for Windows please consult the doc/INSTALL.win file.<h3><a class="anchor" name="FromSource">
+From Source</a></h3>
+<h4><a class="anchor" name="Prerequisites">
+Prerequisites</a></h4>
+These UDFs require that the libpcre headers and library are installed. For debian/ubuntu type systems, installing libpcre3-dev should be sufficient. (<em>apt-get install libpcre3-dev</em>).<h4><a class="anchor" name="Compilation">
+Compilation</a></h4>
+Most users should be able to simply type: <em>./configure ; make install</em><p>
+If mysql is an unusual place, you might need to add --with-mysql=&lt;mysql directory&gt;/bin/mysql_config.<p>
+Similarly, if licpcre is in an unusual place, --with-pcre can be added.<p>
+Example (for osx using fink): ./configure --with-pcre=/sw --with-mysql=/sw/bin/mysql_config<p>
+Also, version 1.1 changes the way NULLs are handled. To restore the legacy NULL handling, add --enable-legacy-nulls to the configure line<h4><a class="anchor" name="">
+</a></h4>
+Provided the library has been installled into a directory that mysql server already has in its LD_LIBRARY_PATH, installation of the functions should be as easy as typing: <em>make installdb</em>. Any problems encountered are likely related to the server's environment and the installation directory. If no problems are encountered, type <em>make test</em> to perform some basic tests.<h3><a class="anchor" name="WindowsBinaries">
+Windows Binaries</a></h3>
+There is a zip file, downloadable from this site, that contains the necessary dll files to run this UDF on windows. One of these dll files is the UDF, itself, and the other required dll file is the PCRE library. These files both need to be installed in directories where the MySQL server can find them. For the 5.0 series of mysql server, this should be the bin directory directly under the Mysql\ Server installation. For the 5.1 MySQL servers this is the directory as specified by the 'plugin_dir' MySQL variable. After copying the files and restarting the server, the 3rd file in the archive can be used to create the functions.<p>
+For more information, please consult the doc/INSTALL.windows file in the source package.<p>
+<br>
+ <h2><a class="anchor" name="Functions">
+Functions</a></h2>
+lib_mysqludf_preg provides the following functions that interface with the PCRE library.<p>
+<ul>
+<li><a class="el" href="index.html#PREG_CAPTURE_SECTION">preg_capture</a> capture a parenthesized subexpression from a PCRE pattern</li>
+</ul>
+<ul>
+<li><a class="el" href="index.html#PREG_CHECK_SECTION">preg_check</a> check if a string is a valid perl-compatible regular expression</li>
+</ul>
+<ul>
+<li><a class="el" href="index.html#PREG_POSITION_SECTION">preg_position</a> get position of the of a regular expression capture group in a string</li>
+</ul>
+<ul>
+<li><a class="el" href="index.html#PREG_REPLACE_SECTION">preg_replace</a> perform regular expression search &amp; replace using PCRE.</li>
+</ul>
+<ul>
+<li><a class="el" href="index.html#PREG_RLIKE_SECTION">preg_rlike</a> test if a string matches a perl-compatible regular expression</li>
+</ul>
+<ul>
+<li><a class="el" href="index.html#LIB_MYSQLUDF_PREG_INFO_SECTION">lib_mysqludf_preg_info</a> get information about the installed lib_mysqludf_preg library</li>
+</ul>
+<br>
+ <h2><a class="anchor" name="PREG_CAPTURE_SECTION">
+preg_capture</a></h2>
+capture a parenthesized subexpression from a PCRE pattern<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION preg_capture RETURNS STRING SONAME 'lib_mysqludf_preg.so';</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>PREG_CAPTURE( pattern , subject [, group] [, occurence] )</dd></dl>
+<dl class="user" compact><dt><b></b></dt><dd></dd></dl>
+<dl compact><dt><b>Parameters:</b></dt><dd>
+ <table border="0" cellspacing="2" cellpadding="0">
+ <tr><td valign="top"></td><td valign="top"><em>pattern</em>&nbsp;</td><td>- is a string that is a perl compatible regular expression as documented at: <a href="http://us.php.net/manual/en/ref.pcre.php">http://us.php.net/manual/en/ref.pcre.php</a> This expression passed to this function should have delimiters and can contain the standard perl modifiers after the ending delimiter.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>subject</em>&nbsp;</td><td>-is the data to perform the match &amp; capture on</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>group</em>&nbsp;</td><td>- is the capture group that should be returned. This can be a numeric capture group or a named capture group. Numeric groups should be passed in as integers while named groups should be strings. If not speficied, this defaults to 0, which will capture the entire matching regular expression.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>occurence</em>&nbsp;</td><td>- which match of the regex to perform capture on. This is useful for subjects that have multiple matches of the pattern. If not speficied, this defaults to 1, which will capture the requested group, from the first matching occurence of the pattern.</td></tr>
+ </table>
+</dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>- string that was captured - if there was a match and the desired capture group is valid <p>
+- string that is the entire portion of subject which matches the pattern - if 0 is passed in as the group and pattern matches subject <p>
+- NULL - if pattern does not match the subject or group is not a valid capture group for the given pattern and subject.</dd></dl>
+preg_capture is a udf that captures parenthesized sub-expressions from a pcre pattern.<p>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd></dd></dl>
+SELECT PREG_CAPTURE('/(.*?)(fox)/' , 'the quick brown fox' ,2 );<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
++----------------------------------------------------------+
+| PREG_CAPTURE('/(.*?)(fox)/' , 'the quick brown fox' ,2 ) |
++----------------------------------------------------------+
+| fox |
++----------------------------------------------------------+
+</pre></div><p>
+SELECT PREG_CAPTURE( '/"([^"]+)"/' , 'the "quick" brown fox "jumped" over the "lazy" dog' , 1,2 );<p>
+<div class="fragment"><pre class="fragment">
++--------------------------------------------------------------------------------------------+
+| PREG_CAPTURE( '/"([^"]+)"/' , 'the "quick" brown fox "jumped" over the "lazy" dog' , 1,2 ) |
++--------------------------------------------------------------------------------------------+
+| jumped |
++--------------------------------------------------------------------------------------------+
+</pre></div><p>
+SELECT PREG_CAPTURE( '/b[^\s]+/' , 'the quick brown fox jumped over' )<p>
+<b>Yields:</b> <p>
+<div class="fragment"><pre class="fragment">
++------------------------------------------------------------------+
+| PREG_CAPTURE( '/b[^\\s]+/' , 'the quick brown fox jumped over' ) |
++------------------------------------------------------------------+
+| brown |
++------------------------------------------------------------------+
+</pre></div><p>
+<dl class="note" compact><dt><b>Note:</b></dt><dd>Remember to add a backslash to escape patterns that use \ notation </dd></dl>
+<p>
+<br>
+ <h2><a class="anchor" name="PREG_CHECK_SECTION">
+preg_check</a></h2>
+Test if a perl-compatible regular expression is valid<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION preg_check RETURNS INTEGER SONAME 'lib_mysqludf_preg.so';</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>PREG_CHECK( pattern )</dd></dl>
+<dl class="user" compact><dt><b></b></dt><dd></dd></dl>
+<dl compact><dt><b>Parameters:</b></dt><dd>
+ <table border="0" cellspacing="2" cellpadding="0">
+ <tr><td valign="top"></td><td valign="top"><em>pattern</em>&nbsp;</td><td>- is a string that might be a perl compatible regular expression as documented at: <a href="http://us.php.net/manual/en/ref.pcre.php">http://us.php.net/manual/en/ref.pcre.php</a></td></tr>
+ </table>
+</dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 - the pcre is valid <p>
+0 - the pcre is NULL, empty, or a bad regex</dd></dl>
+preg_check is a udf that tests if whether or not the given perl compatible regular expression is valid. This is a useful companion to the other functions in the lib_mysqludf_pref library in that those functions all return errors (and stop processing) when empty, NULL, or incorrect regular expressions are passed in to them. If pcre patterns are stored in rows of a database and it is not confirmed that the patterns are valid, PCRE_CHECK is useful either as a filter used in conjunction with those calls or as a separate query to help cleanup the database before using those other functions.<p>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd></dd></dl>
+SELECT PREG_CHECK('/The quick brown fox/i' );<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
+ +---------------------------------------------------------------+
+ | PREG_CHECK('/The quick brown fox/i' ) |
+ +---------------------------------------------------------------+
+ | 1 |
+ +---------------------------------------------------------------+
+</pre></div><p>
+SELECT * from patterns WHERE PREG_CHECK( pattern );<p>
+Yields: all of the rows containing valid pcre's. <p>
+<br>
+ <h2><a class="anchor" name="PREG_POSITION_SECTION">
+preg_position</a></h2>
+get position of the of a regular expression capture group in a string<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION preg_position RETURNS INTEGER SONAME 'lib_mysqludf_preg.so';</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>PREG_POSITION( pattern , subject [, group] [, occurence] )</dd></dl>
+<dl class="user" compact><dt><b></b></dt><dd></dd></dl>
+<dl compact><dt><b>Parameters:</b></dt><dd>
+ <table border="0" cellspacing="2" cellpadding="0">
+ <tr><td valign="top"></td><td valign="top"><em>pattern</em>&nbsp;</td><td>- is a string that is a perl compatible regular expression as documented at: <a href="http://us.php.net/manual/en/ref.pcre.php">http://us.php.net/manual/en/ref.pcre.php</a> This expression passed to this function should have delimiters and can contain the standard perl modifiers after the ending delimiter.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>subject</em>&nbsp;</td><td>-is the data to perform the match &amp; position capture on</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>group</em>&nbsp;</td><td>- the capture group whose position that should be returned. This can be a numeric capture group or a named capture group. Numeric groups should be passed in as integers, while named groups should be strings. 0 should be used to request to position of the entire matching expression. This parameter defaults to 0.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>occurence</em>&nbsp;</td><td>- which match of the regex to perform capture on. This is useful for subjects that have multiple matches of the pattern. This parameter defaults to 1.</td></tr>
+ </table>
+</dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>- integer position of the string that was captured - if there was a match and the desired capture group and occurence is valid <p>
+- NULL if pattern does not match the subject or group is not a valid capture group or the occurence is larger than the number of matches for the given pattern and subject.</dd></dl>
+preg_position is a udf that captures the position of matching regular expression from a pcre pattern. It can be useful when strings need to be split by a pcre pattern or if the location of the pattern within the string is needed for some other reason.<p>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd></dd></dl>
+SELECT PREG_POSITION('/(.*?)(fox)/' , 'the quick brown fox' ,2 );<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
++-----------------------------------------------------------+
+| PREG_POSITION('/(.*?)(fox)/' , 'the quick brown fox' ,2 ) |
++-----------------------------------------------------------+
+| 17 |
++-----------------------------------------------------------+
+</pre></div><p>
+SELECT PREG_POSITION('/"[^"]+"/' , '"quick","brown","fox" "jumped"',0,4)<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
++-------------------------------------------------------------------+
+| PREG_POSITION('/"[^"]+"/' , '"quick","brown","fox" "jumped"',0,4) |
++-------------------------------------------------------------------+
+| 23 |
++-------------------------------------------------------------------+
+</pre></div><p>
+<dl class="note" compact><dt><b>Note:</b></dt><dd>Remember to add a backslash to escape patterns that use \ notation. The returned position starts at 1 for the first character, as is standard for MySQL string functions. </dd></dl>
+<p>
+<br>
+ <h2><a class="anchor" name="PREG_REPLACE_SECTION">
+preg_replace</a></h2>
+performs regular expression search &amp; replace using PCRE.<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION preg_replace RETURNS STRING SONAME 'lib_mysqludf_preg.so';</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>PREG_REPLACE( pattern , replacement , subject [ , limit ] )</dd></dl>
+<dl class="user" compact><dt><b></b></dt><dd></dd></dl>
+<dl compact><dt><b>Parameters:</b></dt><dd>
+ <table border="0" cellspacing="2" cellpadding="0">
+ <tr><td valign="top"></td><td valign="top"><em>pattern</em>&nbsp;</td><td>- is a string that is a perl compatible regular expression as documented at: <a href="http://us.php.net/manual/en/ref.pcre.php">http://us.php.net/manual/en/ref.pcre.php</a> This expression passed to this function should have delimiters and can contain the standard perl modifiers after the ending delimiter.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>replacement</em>&nbsp;</td><td>- is the string to use as the replacement. This string may contain capture group references such as \1. You can also use $1 for these in a similar fashion as in PHP.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>subject</em>&nbsp;</td><td>-is the data to perform the match &amp; replace on</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>limit</em>&nbsp;</td><td>- optional number that is the maximum replacements to perform. Use -1 (or leave empty) for no limit.</td></tr>
+ </table>
+</dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>- string - 'subject' with the instances of pattern replaced <p>
+- string - the same as passed in if there were no matches</dd></dl>
+preg_replace is a udf that performs a regular expression search and replace on a given piece of data using a PCRE as the replacement pattern. If limit is not speficied or is -1, preg_replace works on all of the ocurrences of the pattern in the subject data. Otherwise, preg_replace will only replace the first &lt;limit&gt; occurences.<p>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd></dd></dl>
+SELECT PREG_REPLACE('/(.*?)(fox)/' , '$1dog' , 'the quick brown fox' );<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
++-----------------------------------------------------------------+
+| PREG_REPLACE('/(.*?)(fox)/' , '$1dog' , 'the quick brown fox' ) |
++-----------------------------------------------------------------+
+| the quick brown dog |
++-----------------------------------------------------------------+
+</pre></div><p>
+SELECT PREG_REPLACE('/\s\s/+', ' ' , products.title FROM products;<p>
+Yields: The product names with all of the extra whitespace removed<p>
+<dl class="note" compact><dt><b>Note:</b></dt><dd>Remember to add a backslash to escape patterns that use \ notation. Also, using $ notation makes things a little clearer when using backreferences in the replacement. </dd></dl>
+<p>
+<br>
+ <h2><a class="anchor" name="PREG_RLIKE_SECTION">
+preg_rlike</a></h2>
+Test if a string matches a perl-compatible regular expression<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION preg_rlike RETURNS INTEGER SONAME 'lib_mysqludf_preg.so';</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>PREG_RLIKE( pattern , subject )</dd></dl>
+<dl class="user" compact><dt><b></b></dt><dd></dd></dl>
+<dl compact><dt><b>Parameters:</b></dt><dd>
+ <table border="0" cellspacing="2" cellpadding="0">
+ <tr><td valign="top"></td><td valign="top"><em>pattern</em>&nbsp;</td><td>- is a string that is a perl compatible regular expression as documented at: <a href="http://us.php.net/manual/en/ref.pcre.php">http://us.php.net/manual/en/ref.pcre.php</a> This expression passed to this function should have delimiters and can contain the standard perl modifiers after the ending delimiter.</td></tr>
+ <tr><td valign="top"></td><td valign="top"><em>subject</em>&nbsp;</td><td>- is the data to perform the test on.</td></tr>
+ </table>
+</dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>1 - a match was found <p>
+0 - no match</dd></dl>
+preg_rlike is a udf that tests if whether or not the given perl compatible regular expression matches the given data.<p>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd></dd></dl>
+SELECT PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' );<p>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
+ +---------------------------------------------------------------+
+ | PREG_RLIKE('/The quick brown fox/i' , 'the quick brown fox' ) |
+ +---------------------------------------------------------------+
+ | 1 |
+ +---------------------------------------------------------------+
+</pre></div><p>
+SELECT * from products WHERE PREG_RLIKE( '/organic/i' , products.title )<p>
+Yields: all of the products with 'organic' in their titles <p>
+<br>
+ <h2><a class="anchor" name="LIB_MYSQLUDF_PREG_INFO_SECTION">
+lib_mysqludf_preg_info</a></h2>
+Return version information for lib_mysqludf_preg package<p>
+<dl class="user" compact><dt><b>Function Installation</b></dt><dd>CREATE FUNCTION lib_mysqludf_preg_info RETURNS STRING SONAME 'lib_mysqludf_preg.so' ;</dd></dl>
+<dl class="user" compact><dt><b>Synopsis</b></dt><dd>LIB_MYSQLUDF_PREG_INFO()</dd></dl>
+<dl class="return" compact><dt><b>Returns:</b></dt><dd>string - version information for the lib_mysqludf_preg package</dd></dl>
+<dl class="user" compact><dt><b>Examples:</b></dt><dd>SELECT LIB_MYSQLUDF_PREG_INFO();</dd></dl>
+<b>Yields:</b> <div class="fragment"><pre class="fragment">
++--------------------------+
+| LIB_MYSQLUDF_PREG_INFO() |
++--------------------------+
+| lib_mysqludf_preg 0.6.1 |
++--------------------------+
+ </pre></div> </div>
+<hr size="1"><address style="text-align: right;"><small>Generated on Sat Mar 23 18:24:07 2013 for lib_mysqludf_preg by&nbsp;
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
+</body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.