emexinc Posted December 2, 2008 Share Posted December 2, 2008 Here is my example coding... $item = "2 3/8\" x 3\" Heritage Railing w/ Bottom"; $item = preg_replace("/[a-w,y-z,A-W,Y-Z]/", "", $item); echo $item; // this echo's 2 3/8" x 3" / ...my problem, I do not want to escape all the "/", but I would like to drop that lonely one sitting at the end... p.s. i know my preg_replace looks funny, but that's the easiest way i could think of escaping everything except the "x" between the two listed sizes...this will work as long as there are no further "x" in the descriptions that i am trying to edit ...thanks...d Quote Link to comment https://forums.phpfreaks.com/topic/135249-solved-escaping-a-stranded-charater/ Share on other sites More sharing options...
DarkWater Posted December 2, 2008 Share Posted December 2, 2008 ...What? Quote Link to comment https://forums.phpfreaks.com/topic/135249-solved-escaping-a-stranded-charater/#findComment-704471 Share on other sites More sharing options...
johnsmith153 Posted December 3, 2008 Share Posted December 3, 2008 He's trying to use the " to explain inches (2 and three eighths of an inch by 3 inches) Forget that shit, just: either: (1) $item = '2 3/8" x 3" Heritage Railing w/ Bottom'; (2) $item = "2 3/8" x 3" Heritage Railing w/ Bottom"; (3) in. - abbreviation for inches You wont need the preg_replace bit either. Couldn't you get this DarkWater?? Quote Link to comment https://forums.phpfreaks.com/topic/135249-solved-escaping-a-stranded-charater/#findComment-704483 Share on other sites More sharing options...
emexinc Posted December 3, 2008 Author Share Posted December 3, 2008 Here is my example coding... $item = "2 3/8\" x 3\" Heritage Railing w/ Bottom"; $item = preg_replace("/[a-w,y-z,A-W,Y-Z]/", "", $item); echo $item; // this echo's 2 3/8" x 3" / ...my problem, I do not want to escape all the "/", but I would like to drop that lonely one sitting at the end... p.s. i know my preg_replace looks funny, but that's the easiest way i could think of escaping everything except the "x" between the two listed sizes...this will work as long as there are no further "x" in the descriptions that i am trying to edit ...thanks...d ...sorry, I didn't realize the confusion that I created with this...let me clarify my question... ...if this is my original output from a database... $item = '2 3/8" x 3" Heritage Railing w/ Bottom'; ...if I do the following... $item = preg_replace("/[a-w,y-z,A-W,Y-Z]/", "", $item); ...after an echo, this outputs... 2 3/8" x 3" / ...now I have a useless "/" at the end, but I cannot include that in the preg_replace because I do need it between the "3" and the "8"...and some records will also have an extra measurement size as well... 2 3/8" x 3" x 2 1/4" / ...so, how can I go about eliminating the "/" at the end...I really hope I've clarified myself...sorry once again... Quote Link to comment https://forums.phpfreaks.com/topic/135249-solved-escaping-a-stranded-charater/#findComment-704498 Share on other sites More sharing options...
.josh Posted December 3, 2008 Share Posted December 3, 2008 if your $item is always going to start with the dimensions... preg_match("/.*\"/",$item, $result); echo $result[0]; Quote Link to comment https://forums.phpfreaks.com/topic/135249-solved-escaping-a-stranded-charater/#findComment-704501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.