Here is the code :
lines = re.split('\\s*\\n+\\s*', text)
joint_stack = []
for line in lines:
words = re.split('\\s+', line)
instruction = words[0]
My JS code is :
_parse_hierarchy(text) {
var lines = text.split('\\s*\\n+\\s*');
console.log("Test _parse_hierarchy -> ", lines);
I got array but i got whole text in one item. My array length is 1.
Looks like i need regex to split by line...
I also try var lines = text.match('\\s*\\n+\\s*'); with no success.
Any suggestion ?
Correct way for js format: \\ => \
and without ' or " .
var lines = text.split(/\s*\n+\s*/);
console.log("Test lines -> ", lines);
for (var key in lines) {
var line = lines[key];
console.log("Test _parse_hierarchy FIRST WORD -> ", line);
var words = line.split(/\s+/);
// var firstword = words[0];