Link to home
Start Free TrialLog in
Avatar of n00b0101
n00b0101

asked on

jquery find / replace arrays?

I'm trying to learning about pattern matching with jQuery and I had a question...

In php, I can do something like this:

$find = array("-", "_", "+");
$replace = array("X", "Y", "Z");

$string = "The alphabet ends in -, _, +";
$newstring = str_replace($find, $replace, $string); 

Open in new window


Which will yield: The alphabet ends in X, Y, Z

Is there a way to accomplish this with jquery?  Where I can define an array of values to search for and replace them with the values in another array?  I get that I can do a replace(/pattern/, "Something"), but was hoping for a way to duplicate this php code in jquery?
SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India 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
ASKER CERTIFIED SOLUTION
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