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
https://forums.phpfreaks.com/topic/7960-regular-expressions/
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
https://forums.phpfreaks.com/topic/7960-regular-expressions/#findComment-29017
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.