Re: search string
| From: | Andrew Kreps | Date: | Fri, 21 Jul 2006 20:27:37 +0000 |
| Subject: | Re: search string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239693@lists.php.net to get a copy of this message | ||
You can use a regular expressions with a function called preg_match to
find the values. For example,
(Assuming your sql statement is $sql)
preg_match("/(tbl_chassis.chasis_model LIKE \'\%[a-zA-Z0-9-]+\%\'/)",
$sql, $matches);
That will return $matches[0] with the matched data. Similarly,
preg_match("/(AND lower\(country\) = lower\(trim\(\'(\w+)\'\)\))/",
$sql, $matches);
does the same thing, again in $matches[0].
The full description of preg_match can be found here:
http://us2.php.net/manual/en/function.preg-match.php
On 7/20/06, weetat <weetat.yeo@cxrus.com> wrote:
Hi all , I am using php4.3.2,MYSQL and RedHat I have a sql text as shown below: SELECT DISTINCT(tbl_chassis.serial_no),tbl_chassis.host_name,tbl_chassis.chasis_model,tbl_chassis.country,tbl_chassis.city,tbl_chassis.building, tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3 from tbl_chassis tbl_chassis,tbl_card tbl_card WHERE tbl_chassis.serial_no = tbl_card.serial_no AND tbl_chassis.chasis_model LIKE '%WS-C5500%' AND lower(country) = lower(trim('Malaysia')) ORDER BY country,city,building,other I need to extract the "tbl_chassis.chasis_model LIKE '%WS-C5500%'" and "lower(country) = lower(trim('Malaysia'))" and join them to new string. Anyone have any suggestion how to do this? Thanks -weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php