D
D
Diversia2018-09-05 11:20:31
JavaScript
Diversia, 2018-09-05 11:20:31

How to get the value from a string?

There is a line: Please tell me how to get only the number 16?
var name = "Супер сериал 2018 (16 серий)";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Loginov, 2018-09-05
@Diversia

To do this, you need to use regular expressions, in this case:

var name = "Супер сериал 2018 (16 серий)";
var new_name = name.replace(/^(.*?)\(([0-9]+)(.*)$/, '$2');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question