Jump to content

regular expressions


Ninjakreborn

Recommended Posts

What are the purposes of the following< please note I have done extensive research, I found alot of tutorials telling me about them, how to utilize them, this is great, but what is the "purpose" of them, in general programming when will the "need" arise for me to have to use it
preg_match()
preg_matchall()
and other things of those nature, if you have some ideas I would appreciate it, if I know there is a reason then we can work something.
Link to comment
Share on other sites

Regular expression allow you to check/manipulate large strings based on very small parts of it.

An example -

Like this site where ever someone enters the word 'php' you want to link it to php.net

string is "I progam in php because it is not made by microsoft and its dead nice and you can do loads with php."

$string = preg_replace('/(php)(\.| )/','<a href="http://www.php.net">\\1</a>\\2',$string);

should return...

I progam in <a href="http://www.php.net">php</a> because it is not made by microsoft and its dead nice and you can do loads with <a href="http://www.php.net">php</a>.

Basically it allows you to control all manner of aspects of the string or get all manner of info from a string based on small parts of it without you having to know the exact content of the string before hand.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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

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.