CSRF whitelist supports regex

Signed-off-by: Casey Hancock <crh431@gmail.com>
diff --git a/system/core/Security.php b/system/core/Security.php
index 741ff22..a6fd75f 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -203,10 +203,13 @@
 		if ($exclude_uris = config_item('csrf_exclude_uris'))
 		{
 			$uri = load_class('URI', 'core');
-			if (in_array($uri->uri_string(), $exclude_uris))
-			{
-				return $this;
-			}
+			foreach ($exclude_uris as $excluded) {
+                		$excluded = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $excluded);
+                		if (preg_match('#^'.$excluded.'$#', $uri->uri_string()))
+                		{
+                    			return $this;
+                		}
+            		}
 		}
 
 		// Do the tokens exist in both the _POST and _COOKIE arrays?
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 2ed2275..2d523e9 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -507,7 +507,7 @@
 
       -  Added method ``strip_image_tags()``.
       -  Added ``$config['csrf_regeneration']``, which makes token regeneration optional.
-      -  Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run.
+      -  Added ``$config['csrf_exclude_uris']``, which allows you list URIs which will not have the CSRF validation methods run. Optionally allows regex.
       -  Modified method ``sanitize_filename()`` to read a public ``$filename_bad_chars`` property for getting the invalid characters list.
       -  Return status code of 403 instead of a 500 if CSRF protection is enabled but a token is missing from a request.
 
diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst
index fb875a0..5669243 100644
--- a/user_guide_src/source/libraries/security.rst
+++ b/user_guide_src/source/libraries/security.rst
@@ -97,6 +97,12 @@
 
 	$config['csrf_exclude_uris'] = array('api/person/add');
 
+Optionally, you can use regular expressions as well as the ':any' and ':num'
+wildcards in the URIs::
+
+	$config['csrf_exclude_uris'] = array('api/record/:num','api/title/[a-zA-Z]+');
+	
+
 ***************
 Class Reference
 ***************