Jump to content
Xisto Corporation

The Absolute Bare Minimum Every Programmer Should Know About Regular Expressions

Recommended Posts

Well, the title says it all and I really don't have anything to add to that, except to say that this is a really, really powerful technology that is very pervasive in many programming as well as scripting languages and as well in mainstream database products.

I really recommend you put in the time and effort to learn regular expressions, they are power tools that are going to open for you a whole new world of text processing possibilities.


Share this post

Link to post
Share on other sites

regexp in PHP Arrays:

Clear blanks:

$array = preg_grep('/[^$]/', $array);

Patterns for zip codes
$zip_code = str_replace(' ','','ZIP CODE');	$pattern = array(	  array(		'/^[[:alnum:]]{6,6}+$/',		'/[[:alpha:]]/',		'/[[:digit:]]/'	  ),	  array(		'/^(\d){5,5}+$/'	  )	);		$is_zip_code = true	for($_j = 0; $_j < count($pattern[$_i]); $_j++){	  $is_zip_code = ($is_zip_code and preg_match($pattern[$_i][$_j],$zip_code));	}

Regexp have power to resume your code in rules, then you are able to change the pattern easily.
There are many tools to create regexp patterns.

Edited by develCuy

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.