php preg_match_all brackets
I'm stuck with a bit of php code, I am getting information of a site which has information inside brackets, the problem is I only want the information infront of the brackets, since the content of the brackets can be anything I am confused what to do...
preg_match_all('/<title>FlightAware >(.*?) <\/title>/ms', $title, $airports, PREG_SET_ORDER);
this is what I have the actual title is: FlightAware > London Heathrow Airport (London, England) EGLL开发者_如何学C / LHR Flug-Tracker
All I would like from that is the "London Heathrow Airport"... any ideas?
preg_match_all('/<title>FlightAware >(.*)\(.+\).+<\/title>/ms', $title, $airports, PREG_SET_ORDER);
If it's stored as
<title>FlightAware > London Heathrow Airport (London, England) EGLL / LHR Flug-Tacker</title>
You could try
/<title>FlightAware > (.+?) \((.+?)\)(.+?)<\/title>/ms
Which should give you just London Heathrow Airport
. You'll have London, England
in the second match parameter, and EGLL / LHR Flug Tracker-
in the third match parameter. Granted, this is only if that is the EXACT format each one is stored in.
Also, work on your accept rating.
精彩评论