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 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? 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?? 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... 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]; 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
Archived
This topic is now archived and is closed to further replies.