Jump to content

[SOLVED] Escaping a stranded charater


emexinc

Recommended Posts

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

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?? :)

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.