Regular Expressions Class

The Regular Expressions class contains functions that process and validate strings using regular expressions.

valid_email(address [string])

Finds whether a string is a valid email.

Class: Regex (REGX)

Description: When given str, it will return true if str is a valid email, false otherwise.

valid_ip(ip [string])

Finds whether string is a valid ip.

Class: Regex (REGX)

Description: When given ip it will return true if ip is in the form of a valid ip address, false otherwise.

prep_url(str [string])

Makes string valid external url

Class: Regex (REGX)

Description: Returns str after checking to make sure it has http:// in front of it.

prep_query_string(str [string])

Makes string valid system url

Class: Regex (REGX)

Description: Returns str after checking to make sure that if Force Query Strings is set to yes that a '?' is properly places in the system URL. Useful for user submitted URLs (like Weblog URL in Weblog Management), when you wish to make sure it is correct for Force Query String.

decode_qstr(str [string])

Returns string with certain entities decoded

Class: Regex (REGX)

Description: Returns str after converting the HTML entities for ., ?, and & back to those characters. A URL sent by a form, ping, etc. might have these entities encoded prior to sending, so this function makes sure that they are converted back prior to processing.

form_prep(str [string], strip [int])

Returns string with certain characters encoded

Class: Regex (REGX)

Description: Returns str after preparing for use within a form. If the optional parameter strip is set to 1, then stripslashes() will be performed on str as well. Useful for switching template variables (ex: {member_name}) in a form.

encode_php_tags(str [string]

Returns string with PHP tags converted to entities

Class: Regex (REGX)

Description: Returns str after converting the PHP opening and closing tags to entities. Used by the Typography class.

encode_ee_tags(str [string]

Returns string with EE tags converted to entities

Class: Regex (REGX)

Description: Returns str after converting the EE opening and closing tags (ex: {exp:weblog}) to entities. Used by the Typography class.

convert_quotes(str [string])

Converts single and double quotes to entities

Class: Regex (REGX)

Description: Converts just single and double quotes to entities in str and returns str.

xml_convert(str [string])

Converts reserved XML characters

Class: Regex (REGX)

Description: Converts reserved XML characters in str and returns str. The following values are encoded: \&, <, >, \\, ', -. Note: HTML Entities are kept safe and their ampersands are not converted.

ascii_to_entities(str [string])

Converts ASCII to Entities

Class: Regex (REGX)

Description: Returns str after converting higher ASCII values into HTML entities where possible. Only use when the auto_convert_high_ascii config file preference is set to yes (i.e. $PREFS->ini('auto_convert_high_ascii') == 'y').

entities_to_ascii(str [string], all [boolean])

Entities to ASCII

Class: Regex (REGX)

Description: Converts HTML entities into ASCII values and returns str. If all is set to TRUE (TRUE is default), it will also convert all XML reserved charcters (&, <, >, ', ", -) from entity form back to ASCII. Used mostly in forms and email message sending.

trim_slashes(str [string])

Trim slashes from string

Class: Regex (REGX)

Description: Trims forward slashes (/) from front and back of str and returns str. It will also remove slashes that are in the form of an HTML Entity.

remove_extra_commas(str [string])

Removes extra commas from string

Class: Regex (REGX)

Description: Removes double commas from str, and then removes any commas from beginning and end of str. Returns str. Used for cleaning up user inputted values separated by commas.

strip_quotes(str [string])

Removes quotes from string

Class: Regex (REGX)

Description: Returns str after removing standard (not curly) single and double quotes.

keyword_clean(str [string])

Cleans search keywords

Class: Regex (REGX)

Description: Returns str after removing naughty, unwanted stuff and cleaning it up a bit.

convert_dissallowed_chars(str [string])

Converts Disallowed Characters to Entities

Class: Regex (REGX)

Description: Returns str after converting disallowed characters (parentheses, dollar sign, etc) to entities.

xss_clean(str [string])

Removes malicious code from string

Class: Regex (REGX)

Description: Removes from str known malicious pieces of code that no non-malicious user would enter. Highly recommened for cleaning incoming user data. Returns str.

Note: Incoming $_GET and $_COOKIE data are passed through this function by the system, but $_POST and $_SERVER data is not.

create_url_title(str [string])

Creates valid url title from string

Class: Regex (REGX)

Description: Takes str and returns a valid url_title based on that string. Use for importing or creation of entries.

unhtmlentities(str [string])

Convert HTML Entities Back to Characters

Class: Regex (REGX)

Description: Takes str and returns with all entities turned into their characters.

array_stripslashes(data [array])

Removes Slashes From Array

Class: Regex (REGX)

Description: Takes array and returns it with all forward slashes removed from all of the values, does multi-dimensional arrays too.

Top of Page