php - Extract specific part of URL from string -


I need to remove only parts of a URL with PHP, but I set the point where the clearance off I'm struggling for. I have used a regex to remove the entire URL from a long string like this:

  $ regex = '/ \ b (https | FTP | file?): \ / \ / [- a ? Z0-9 + & amp; @ # \ /% = ~ _ | $:.,;] * [One-Z0-9 + & amp; @ # \ /% = ~ _ | $] / I '; Preg_match_all ($ regex, $ href, $ matches);  

The result is the following string:

  http://www.cambridgeenglish.org/test-your-english/&sa= U & Amp; Amp; Ei = a4rbU8agB-zY0QWS_IGYDw & amp; Amp; Vedas = 0CFEQFjAL & amp; Amp; USG = AFQjCNGU4FMUPB2ZuVM45OoqQ39rJbfveg  

Now I just want to remove this bit I basically & amp;

How can anyone get this idea? Do I need to run a regex or can I add in the initial one?

After "text" itemprop = "text">

will be regex below string end after getting rid of everything your PHP The code will be,

   

Explanation:

  • & Amp; ; Amp string & amp; Amp matches .
  • . * matches any character with zero or more times.
  • End of line> $ .

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -