I am feeling exhausted right now and struggling to solve a simple problem.
The format of the string I have is as follows:
BROADCAST FROM x\ny\nz
Here, x
represents a single word without any spaces or newlines, y
is a number, and z
is a string with a length of y
characters.
All I need is to identify the starting index of z
so that I can use string.slice(indexOfZ)
.
Could someone guide me on creating a regular expression in JavaScript for this purpose?
Perhaps it should look something like this...
pattern = /\n[0-9]{1,}\n.*/;
var index = string.match(pattern);
Do you see any mistakes in my approach?