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"
            Asked
            
        
        
            Active
            
        
            Viewed 67 times
        
    -2
            
            
        - 
                    3Take a look at String.split() – Kade M. Oct 31 '19 at 18:03
- 
                    `"Lancer Square super / CIT".split(/\s*\/\s*/)` – adiga Oct 31 '19 at 18:21
2 Answers
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
