Поскольку в вашем наборе данных, который вы можете иметь в заголовке a :
, лучше использовать RegEx, например, ниже
15011721827:52352403:War of the League of the Indies
9428491646:27687104:Deepwater Pathfinder
3524782652:4285058:Wikipedia:Articles for deletion/Joseph Prymak
2302538806:1870985:Cardinal Infante Ferdinand`
В третьей строке есть :
, которые отделяют Википедию от остальной частиЗаголовок, если вы используете функцию split
, у вас будет массив с 4 вместо 3 частей.Чтобы избежать такого рода проблем, я решил использовать регулярное выражение
var pattern = /^(\d+):(\d+):(.+)$/
var data = "15011721827:52352403:War of the League of the Indies"
var matches = data.match(pattern)
console.log(matches)
// matches[0] = "15011721827:52352403:War of the League of the Indies"
// matches[1] = "15011721827"
// matches[2] = "52352403"
// matches[3] = "War of the League of the Indies"