PHP: preg_replace

Discussion in 'PHP' started by born2hack, Nov 19, 2008.

  1. #1
    Well, I have recentely be coding many PHP applications relating to cURL and mainly I require using preg_replace for retrieving specific info. The problem is I am good @ cURL but not @ preg_replace, I just know this much

    preg_replace("^data before(.*)data after^", $source_code_of_page, $variable_to_contain_data);

    where (.*) is tteh data to be reduced. Can someone explain me more things like (.*) is for data to be taken.

    Mainly I wnat to know what is to be used to tell the script that there can be anything there an dit wont matter like ->

    preg_replace("^this is requiredanything can be here I dont carethis is required(.*)this is required^", $source_code_of_page, $variable_to_contain_data);

    Many thanks!

    Also if anyone can suggest me a godd place JUST FOR preg_replace except for the top 20 results returned by google, I shall be grateful. ;)
     
    born2hack, Nov 19, 2008 IP
  2. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well you have to understand how preg works for for instance to tell it there are letters before the information do [a-z] or number [0-9] or cap letters [A-Z] . i personally use regexbuddy to do my preg calculations. i have read a little at some google searches about the basics and then just go from there .. ill see can i find some links for you
     
    atlantaazfinest, Nov 19, 2008 IP
  3. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #3
    wmtips, Nov 19, 2008 IP