JavaScript String split in 2 arrays string split array,string split array java,string split array

I want to split the following string into 2 arrays.

First array from the beginning to '/' and the second from '/' to end.

Also, I've tryied with replace to remove the '/' but returns error.

var str = 'word1-word2/word3+word4'.replace(/\+|/|-/g,' ');

http://jsbin.com/kubezabemu/1/edit?js,console

The wanted output should be like:

var arr1 = ['word1', 'word2'];
var arr2 = ['word3', 'word4'];
Answer:1

this way you get an array that contains unlimited of your expected arrays

var arr = 'word1-word2/word3+word4'.split("/");

var res = [];
for(var i = 0; i < arr.length; i++){ 
 str=arr[i].replace(/\+|-/g,' ');
 res.push( str.split(" "));
}
console.log(res)

console output

[["word1", "word2"], ["word3", "word4"]]
Answer:2

I am storing an array of objects in localStorage, retriving it each time, attachibg the new object and again storing. the code works fine, only if there is already an entry in localStorage Following ...

I am storing an array of objects in localStorage, retriving it each time, attachibg the new object and again storing. the code works fine, only if there is already an entry in localStorage Following ...

  1. assign json array to javascript variable
  2. assign json array to variable
  3. assign json array to variable php
  4. assign json array to variable c#
  5. assign json array to variable typescript
  6. assign json array to variable in java
  7. json assign array
  8. assign json to array javascript
  9. assign json to array typescript
  10. how to assign json array to javascript variable
  11. assign json array to variable in javascript
  12. javascript assign json array to variable

So I have an HTML table populated with negative and positive values. I want to query the specific values and then upon hovering over the table values less than 0 I want to highlight the row with a red ...

So I have an HTML table populated with negative and positive values. I want to query the specific values and then upon hovering over the table values less than 0 I want to highlight the row with a red ...

url for LinkedIn advanced search: https://www.linkedin.com/vsearch/p?adv=true&trk=advsrch I am trying to fill fields and hit the submit button on the LinkedIn advanced search page using Selenium (...

url for LinkedIn advanced search: https://www.linkedin.com/vsearch/p?adv=true&trk=advsrch I am trying to fill fields and hit the submit button on the LinkedIn advanced search page using Selenium (...

  1. scrapy use selenium
  2. scrapy with selenium
  3. scrapy with selenium tutorial

i am making an app where i need 3d joystick image so that user can swipe on it and image will bend in swipped direction. For swipe down or for swipe up events what css or animation effect i should ...

i am making an app where i need 3d joystick image so that user can swipe on it and image will bend in swipped direction. For swipe down or for swipe up events what css or animation effect i should ...