RegEx Pattern Matching

The RegEx Pattern Matching feature allows you to replace specific terms or strings that may be present in your custom database.sql file. A good example of this is references to the URL of the WordPress site that was used to create the template package. In order to use RegEx pattern matching, simply enter your regex code (as shown below) into your configuration settings under Addons -> IBG App Installer - WP

FORMAT:
$regex = array(RegExValue => NewValue);

VARIABLES:
The following variables can be used to replace data with values generated in the module:

Quick Values

%tempurl% = WordPress Temporary URL
%customurl% = Custom URL as specified in your WordPress configuration settings.
%domainurl% = The domain assigned to the client.
%autourl% = The URL assigned to WordPress (any of the above) as specified in your WordPress configuration settings.
%urlprefix% = The URL prefix assigned to the WordPress site (e.g. either http:// or https://).
%serverip%
 = The client's server IP address.
%firstname%
= The client's first name.
%lastname% = The client's last name.
%email% = The client's e-mail address (also the client's WordPress login).
%companyname% =
The client's company name.
%address1% =
The client's primary address line.
%address2% =
The client's secondary address line.
%city% =
The client's city.
%state% =
The client's state/region.
%postcode% =
The client's postcode.
%country% =
The client's country.
%phonenumber% =
The client's phone number.
%username% =
The client's username for the hosting server.
%password% =
The client's password for the hosting server.
%apppw% =
The client's password for the WordPress account being provisioned.
%defaultblogname%
= The default blog title stored in your WordPress configuration settings.
%defaultblogdesc% = The default blog description stored in your WordPress configuration settings.

Be sure to enclose any of the quick values in single quotes when adding to the regex array string (e.g. '%firstname%').

System Values

$customproductfields["field_name"] = Replace field_name with the name of the custom product field you want to retrieve the value for.
$customclientfields["field_name"] = Replace field_name with the name of the custom client field you want to retrieve the value for.
$configurableoptions["group_name"]["option_name"]["item"] = The item name of the specified configurable option. Replace group_name and option_name with the specific group and corresponding option that you want to retrieve the value for.
$configurableoptions["group_name"]["option_name"]["qty"] = The quantity of the specified configurable option. Replace group_name and option_name with the specific group and corresponding option that you want to retrieve the value for. Note: Yes/No fields return a quantity value of 1 for "checked" and 0 for "unchecked".

EXAMPLE 1:
The default RegEx provided below will replace an existing temporary URL referenced in your database file with the temporary URL for the provisioned site:

$regex = array(
'/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/~\b[a-zA-Z0-9_]+\b)/i'=>'%tempurl%',
);

So if your client's temporary URL was http://111.222.333.444/~youruser and the site you used to create the WordPress package was http://555.666.777.888/~originalsite, the above RegEx code would replace http://555.666.777.888/~originalsite with http://111.222.333.444/~youruser.

EXAMPLE 2:
The below example would replace any reference to the word WordPress (case-insensitive) to the term Awesome Site:

$regex = array(
'/WordPress/i'=>'Awesome Site',
);

EXAMPLE 3:
Multiple replacement terms or patterns can be added by simply creating a seperate array key and value for each one:

$regex = array(
'/FirstWord/i'=>'Cooler Phrase',
'/SecondWord/i'=>'Better Phrase',
);


Excluded Tables

Starting in WordPress Auto-Provision Module v3.0.15, the following tables are excluded by default: _options, _usermeta, _users. Including these tables in the RegEx filtering process was causing site templates or user accounts to break in some instances. If you would like to include these tables in the RegEx search function, please add one of the following lines of code to the bottom of the sqlregex.php file:

To include the _options table, add this line:

$regex_options_table = 1;

To include the _usermeta and _users tables, add this line:

$regex_users_table = 1;


For assistance with constructing a proper RegEx string, please visit http://regex101.com or contact us with any questions.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Installation Steps for IBG App Installer - WP

Getting Started Download and install the latest release of the IBG App Installer - WP module...

Upgrading from the WordPress Auto-Provision Module to the IBG App Installer - WP Module

When upgrading from the WordPress Auto-Provision module to the IBG App Installer - WP module,...

Specifying Language Files

The default language that WordPress is provisioned for is English (en_US). You have the option of...

WordPress Package Builder

The WordPress Package Builder tool helps you easily create your WordPress installation packages...

Managing WordPress Package Folders

When creating or modifying WordPress package folders, please use the guidelines below to ensure...