<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: regular expressions</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: regular expressions</description>
<language>en</language>
<pubDate>Wed, 06 May 2026 17:49:28 +0000</pubDate>

<item>
<title>rafalsak on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-18656</link>
<pubDate>Thu, 04 Jul 2013 17:57:45 +0000</pubDate>
<dc:creator>rafalsak</dc:creator>
<guid isPermaLink="false">18656@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;br /&#62;
I've a problem with my new validation. Here is what I've done:&#60;/p&#62;
&#60;p&#62;In the file: common_validator.php, I included the code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function mf_validate_indeksy($value){
		global $mf_lang;

		$error_message = $mf_lang[&#38;#39;val_indeksy&#38;#39;];

		if(!empty($value[0])){
			$regex  = &#38;#39;/^([0-9]*[\n]?)*$/&#38;#39;;
			$result = preg_match($regex, $value[0]);

			if(empty($result)){
				return sprintf($error_message,&#38;#39;%s&#38;#39;,$value[0]);
			}else{
				return true;
			}
		}else{
			return true;
		}
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In the file: post-functions.php, I included the code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($form_id == 4 &#38;#38;&#38;#38; $element_id == 17){
					$rules[$element_name][&#38;#39;indeksy&#38;#39;] = true;
				}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;after the code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;elseif (&#38;#39;textarea&#38;#39; == $element_type){ //Paragraph

				if($element_info[$element_id][&#38;#39;is_required&#38;#39;]){
					$rules[$element_name][&#38;#39;required&#38;#39;] 	= true;
				}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I expected the result: the filed of type 'Paragaph' and the id = 17 included in the form_id =4,&#60;br /&#62;
should only accept digits and crl\lf (break of line). I mean there is only allowed list of numbers.&#60;/p&#62;
&#60;p&#62;After this changes, there is no result I expected. Please help me ...
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1116</link>
<pubDate>Tue, 18 Mar 2008 09:31:58 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">1116@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Sounds great :-)
&#60;/p&#62;</description>
</item>
<item>
<title>dgrebb on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1103</link>
<pubDate>Mon, 17 Mar 2008 21:44:33 +0000</pubDate>
<dc:creator>dgrebb</dc:creator>
<guid isPermaLink="false">1103@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Thanks so much yuniar. The problem was indeed a bad regex, and I was editing the wrong code, inside &#60;code&#62;process_form_update()&#60;/code&#62;, instead of the code inside &#60;code&#62;process_form()&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Again I commend your work on this project. It will make life much easier on my end.&#60;/p&#62;
&#60;p&#62;Cheers!
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1077</link>
<pubDate>Sat, 15 Mar 2008 07:21:07 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">1077@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I can't seem to make your new regex working either. Let's try using this alternative regex:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//validation to disallow any common html
function validate_fullname($value){

	$error_message = VAL_FULLNAME;
	if(!preg_match(&#38;quot;/^[a-zA-Z0-9 ]*$/&#38;quot;,$value[0])){
		return sprintf($error_message,&#38;#39;%s&#38;#39;,$value[0]);
	}else{
		return true;
	}
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
If you still having trouble, I'll mail you the code.&#60;/p&#62;
&#60;p&#62;Also, the modification in post-functions.php file, make sure you modify the right code inside process_form() function, not inside process_form_update().&#60;/p&#62;
&#60;p&#62;Those two function are similar.
&#60;/p&#62;</description>
</item>
<item>
<title>dgrebb on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1071</link>
<pubDate>Fri, 14 Mar 2008 21:22:12 +0000</pubDate>
<dc:creator>dgrebb</dc:creator>
<guid isPermaLink="false">1071@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;The regex was indeed flawed, however the PHP still seems to fail.&#60;/p&#62;
&#60;p&#62;Here is my new regex: &#60;code&#62;(\&#38;lt;(/?[^\&#38;gt;]+)\&#38;gt;)&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I am attempting check a field for any HTML characters, and return the &#60;code&#62;$errormessage&#60;/code&#62; I've added: &#60;code&#62;define(&#38;#39;VAL_FULLNAME&#38;#39;,&#38;#39;This field may only consist of a-z 0-9 and spaces.&#38;#39;);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Thanks so much for the quick response :)
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1067</link>
<pubDate>Fri, 14 Mar 2008 08:18:55 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">1067@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hmm..it seem you have put it in the right places.&#60;br /&#62;
However, what is this regex do?&#60;/p&#62;
&#60;p&#62;&#60;code&#62;preg_match(&#38;#39;\&#38;lt;&#124;\&#38;gt;&#124;www&#124;\.&#38;#39;,$value[0])&#60;/code&#62;&#60;br /&#62;
&#60;code&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I tested with a simple code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$value[0] = &#38;quot;&#38;lt;b&#38;gt;test&#38;lt;/b&#38;gt;&#38;quot;;

preg_match(&#38;#39;\&#38;lt;&#124;\&#38;gt;&#124;www&#124;\.&#38;#39;,$value[0],$matches);
print_r($matches);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
and I get &#34;Warning:  Delimiter must not be alphanumeric or backslash&#34;&#60;br /&#62;
I think there is some glitch with the regex
&#60;/p&#62;</description>
</item>
<item>
<title>dgrebb on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-1060</link>
<pubDate>Fri, 14 Mar 2008 02:57:21 +0000</pubDate>
<dc:creator>dgrebb</dc:creator>
<guid isPermaLink="false">1060@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I cannot figure out how to create an additional validator.&#60;/p&#62;
&#60;p&#62;In includes/common-validator.php I added the following code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//validation to disallow any common html
	function validate_fullname($value){

		$error_message = VAL_FULLNAME;

		if(preg_match(&#38;#39;\&#38;lt;&#124;\&#38;gt;&#124;www&#124;\.&#38;#39;,$value[0])){
			return sprintf($error_message,&#38;#39;%s&#38;#39;,$value[0]);
		}else{
			return true;
		}
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;directly below this code: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//validation to allow only a-z 0-9 and underscores
	function validate_username($value){

		$error_message = VAL_USERNAME;

		if(!preg_match(&#38;quot;/^[a-z0-9][\w]*$/i&#38;quot;,$value[0])){
			return sprintf($error_message,&#38;#39;%s&#38;#39;,$value[0]);
		}else{
			return true;
		}
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In /includes/post-functions.php, I added:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$rules[$element_name][&#38;#39;fullname&#38;#39;] = true;
$rules[$element_name_2][&#38;#39;fullname&#38;#39;] = true;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;directly below&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;}elseif (&#38;#39;simple_name&#38;#39; == $element_type){ //Simple Name

	if(is_array($processed_elements) &#38;#38;&#38;#38; in_array($element_name,$processed_elements)){
		continue;
	}

	//compound element, grab the other element, 2 elements total
	$element_name_2 = substr($element_name,0,-1).&#38;#39;2&#38;#39;;

	$processed_elements[] = $element_name_2; //put this element into array so that it won&#38;#39;t be processed on next loop

	if($element_info[$element_id][&#38;#39;is_required&#38;#39;]){
		$rules[$element_name][&#38;#39;required&#38;#39;] 	= true;
		$rules[$element_name_2][&#38;#39;required&#38;#39;] = true;
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and also added:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$rules[$element_name_2][&#38;#39;fullname&#38;#39;] = true;
	$rules[$element_name_3][&#38;#39;fullname&#38;#39;] = true;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;directly below:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;}elseif (&#38;#39;name&#38;#39; == $element_type){ //Name -  Extended

	if(is_array($processed_elements) &#38;#38;&#38;#38; in_array($element_name,$processed_elements)){
		continue;
	}

	//compound element, grab the other element, 4 elements total
	//only element no 2&#38;#38;3 matters (first and last name)
	$element_name_2 = substr($element_name,0,-1).&#38;#39;2&#38;#39;;
	$element_name_3 = substr($element_name,0,-1).&#38;#39;3&#38;#39;;
	$element_name_4 = substr($element_name,0,-1).&#38;#39;4&#38;#39;;

	$processed_elements[] = $element_name_2; //put this element into array so that it won&#38;#39;t be processed next
	$processed_elements[] = $element_name_3;
	$processed_elements[] = $element_name_4;

	if($element_info[$element_id][&#38;#39;is_required&#38;#39;]){
		$rules[$element_name_2][&#38;#39;required&#38;#39;] = true;
		$rules[$element_name_3][&#38;#39;required&#38;#39;] = true;
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;What am I missing? Any help is much appreciated :)
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-679</link>
<pubDate>Wed, 30 Jan 2008 10:34:14 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">679@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Go to &#60;strong&#62;includes/common-validator.php&#60;/strong&#62; file and adjust the &#60;strong&#62;validate_required()&#60;/strong&#62; function to use your regex.&#60;/p&#62;
&#60;p&#62;Few functions there, such as validate_email() and validate_phone() are using regex to do validation, you might want to take a look at those for samples plugging in a regex.&#60;/p&#62;
&#60;p&#62;Regarding the space, a space is considered an input too. I decided to let it go instead of trimming it.
&#60;/p&#62;</description>
</item>
<item>
<title>arnaud404 on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-673</link>
<pubDate>Wed, 30 Jan 2008 00:22:45 +0000</pubDate>
<dc:creator>arnaud404</dc:creator>
<guid isPermaLink="false">673@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I have also noticed that a simple 'espace' broke the &#34;required&#34; validation of a field
&#60;/p&#62;</description>
</item>
<item>
<title>arnaud404 on "regular expressions"</title>
<link>https://www.machform.com/forums/topic/regular-expressions#post-671</link>
<pubDate>Tue, 29 Jan 2008 23:24:05 +0000</pubDate>
<dc:creator>arnaud404</dc:creator>
<guid isPermaLink="false">671@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;How deep I have to go to change the &#34;required&#34; option by a &#34;use a regex&#34; which will bring me a lot more into the validation &#38;#38; input validation ?&#60;br /&#62;
(for example, for the number field, use &#34;\d{4}&#34; instead of the basic &#34;required&#34; option)&#60;/p&#62;
&#60;p&#62;this is the same post as my prévious one called &#34;regex?&#34;, but the forum seems to be broken with that keyword in the title (sorry)
&#60;/p&#62;</description>
</item>

</channel>
</rss>
