Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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