Link to home
Start Free TrialLog in
Avatar of Eddie Shipman
Eddie ShipmanFlag for United States of America

asked on

Need regex to use in replace()

I've got some strings that look like this:
Baby & Toddler > Baby Safety > ...

Open in new window

I want to take off the trialing
 > ...

Open in new window


Result should be
Baby & Toddler > Baby Safety

Open in new window


Can't use this:
  str.replace(" > ...", "", str);

Open in new window

I get an error: "invalid regular expression flag A" (in Firebug)

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eddie Shipman

ASKER

It isn't working for me...
my test page ?
No, using your regex in my page located here:
http://www.partreports.com/treetest.php
What is your browser ?


Clipboard02.jpg
Firefox 3.6.10
You forgot to click the '...' in the second dropdown that contains baby Monitors. Do that and see if it still works for you.
If you select anything but the '...' in the last one, it doesn't append the  ' > ...'

seems it work :


Clipboard03.jpg
Not using IE7... Did you actually CLICK on the ... in the second dropdown?
Image1.png
Fixed it...

Modified the .each function to not add the item if it's text = '...' like this:


.each(function() { 
  if($(this).text() != '...') {
    labels.push($(this).text()); 
  }
}); // .each

Open in new window

Now, I don't even need the replace...
lol OK
I'm giving you the points anyway.
This taxonomy is for an e-comemrce package to handle exports of their products to import into GoogleBase.
GoogleBase is the "store" for Google Checkout. You can import your products directly into it and sell from their store.
Good to know! Thanks a lot for the points! Have fun!