Skip to content
Advertisement

Tag: split

How can I split strings of an array by backslash?

sIn my Gatsby project, I am picking up the following data from my WordPress platform: I am processing the coordinates string by splitting it up by pipe (|) and shifting away the first element of the array. See below: That mapping of the object is producing the following: I would like to split the elements of the coordinates array by

why is split returning empty strings even tho capturing parenthesis are not present?

My code: That outputs [“”, “a”, “”, “b”, “”]. Why are the empty strings present? Quoting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split , If separator is a regular expression that contains capturing parentheses, then each time separator is matched, the results (including any undefined results) of the capturing parentheses are spliced into the output array. However, not all browsers support this capability. That’s clearly not

split textarea lines that starts with “-” regex jquery

i am trying to split each textarea line that starts with “-” or “- ” or ” -” into individual span element with specific ID 1,2,3,4 etc.. The closest regex code i found is ^-.+ but it wont work for me like it works on: https://regex101.com/r/yCOvyR/4 My current code is available also here: http://jsfiddle.net/ribosed/468emjct/59/ Thanks for any help. plit and

Advertisement