In this article we'll be taking a closer look at the
split() method and how we can use it in conjunction with regular expressions to split a long string just the way we want.
split(delimiter, limit) method is used on a string, it returns an array of substrings, and uses the
delimiter argument's value as the delimiter. The
delimiter argument can also be specified as a regular expression, which will then be used to search through the original string to find delimiters that match the specified expression.
Additionally, we can specify the optional argument
limit, which specifies how many elements we want in our resulting substring array. Setting
limit=2, for example, will yield an array that contains the first two substrings separated by a delimiter in the original string: