PHP Regex remove unwanted data -


I would like to be able to remove content from a string of data.

This is an example string of Google Maps APIs.

Distance: 70.5 & amp; nbsp; # 160; M (approximately 1 hour 12 minutes) & lt; Br / & gt; Map data & amp; # 169; 2009 Google

I like everything in the middle of the brackets () I then do I preg_split

Can we remove everything from any side? :

$ str = "Distance: 70.5 & amp; # 160; m (about 1 hour 12 minutes)
Map data & amp; # 169; 2009 Google "; $ Start = strpos ($ str, '(') + 1; $ end = strpos ($ str, ')'); $ Content = substr ($ str, $ start, $ end - $ start);

But if you are dead-set when using a regex:

  preg_match ($ str, '/ \ ((* *?) \ ) / ', $ Match); $ Content = $ matches [1];  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -