#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Php regular expression to delete everything between


    i have codes in many php files contained

    file1.php: $newfilename = ew_UniqueFilename($u_sabila_lpi_abc->
    file2.php: $newfilename = ew_UniqueFilename($u_sabila_lpi_def->
    file3.php: $newfilename = ew_UniqueFilename($u_sabila_lpi_ghi->

    how to use regular expression to replace all with below:

    $newfilename = ew_UniqueFilename($this->
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    Start with
    Code:
    /(\$newfilename = ew_UniqueFilename\(\$)\w+/
    and replace with $1 . "this".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    you can use $newstring = preg_replace($pattern,$replacement,$string);function for replacing regex. it would be $newstring=preg_replace('file[0-9]+\.php:[\s](.*?>)','file[0-9]+\.php:[\s](.*?\))', $string); this will give you required string before $this->. you can then append $this-> to the stored variable i.e $newstring=$newstring."$this->";

IMN logo majestic logo threadwatch logo seochat tools logo