1
\n54766392632990,178.32.243.13,wfsdsfsdfs23432,\n54766393632990,178.32.243.13,

Above u can see example of string which I want to parse.. I want to get array if numbers which exist between (\n....,178.32.243.13) .. In this example it will be smth like :

[54766392632990,54766393632990] - how to make it

1
  • What have you tried so far ? Commented May 15, 2018 at 10:53

3 Answers 3

1

Please run this script it full file your requirement

var ss = "\n54766392632990,178.32.243.13,wfsdsfsdfs23432,\n54766393632990,178.32.243.13,"

var ddd = ss.split(",")
console.log(ddd)
var dfd = []
ddd.forEach(function(res){
if(res.startsWith("\n"))
{
    dfd.push(res.replace("\n",""))
}
})
console.log(dfd)

Result [ '54766392632990', '54766393632990' ]

Sign up to request clarification or add additional context in comments.

Comments

0
"\n54766392632990,178.32.243.13,wfsdsfsdfs23432,\n54766393632990,178.32.243.13,"
.split("\n")
.filter((n)=> n!== "")
 .map(n=> parseInt(n.split(",")[0]))

Comments

0

You can do something like this to parse this string

let s = "\n54766392632990,178.32.243.13,wfsdsfsdfs23432,\n54766393632990,178.32.243.13,"
s = s.split("\n");
let array = [];
for(let i=0;i<s.length;i++) {
  let v = s[i].split(",178.32.243.13,");
  for(let j=0;j<v.length;j++) {
    if(!isNaN(parseInt(v[j]))) {
      array.push(v[j]);
    }
  }
}
console.log(array);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.