-2

I have a text in a variable, for example: "Lancer Square super / CIT" and I would like to divide the text into 2 variables after the mark, namely: "Square super" and "CIT"

NAW
  • 3
  • 1

2 Answers2

0

If you want to place the results into 2 separate variables, try something like this:

var initialText =  "Lancer Square super / CIT";
var [string1, string2] = initialText.split(' / ');
Jon Warren
  • 857
  • 6
  • 18
0

this is very simple

try this

let str = "Lancer Square super / CIT";
let part1, part2;

part1 = str.split("/")[0].trim();
part2 = str.split("/")[1].trim();

console.log("part1 is: "+part1);
console.log("part2 is: "+part2);
bhuvnesh pattnaik
  • 1,365
  • 7
  • 14