Jump to content


Photo

regular expressions


  • Please log in to reply
2 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 20 April 2006 - 03:37 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 20 April 2006 - 03:57 PM

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">...hp.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">...p.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.
follow me on twitter @PHPsycho

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 20 April 2006 - 04:12 PM

thanks that gives me some ideas on test programs to learn, I appreciate the "example" thanks.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users