H
H
Hanry6542020-04-23 09:39:34
JavaScript
Hanry654, 2020-04-23 09:39:34

How to get nick from "[id123|nick]" in js?

I just can't figure out how to get only nick from [id123|nick]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stockholm Syndrome, 2020-04-23
@Hanry654

const result = str.match(/\[id\d+\|(.*?)\]/);
const nick = result[1];

A
AlexCraft, 2020-04-23
@AlexCraft

let text = "[id123|nick]"
let result = text.match(/nick/)
console.log(result[0])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question