We can use:
^: match the beginning
$: match the end
Let's say we have the string like the following:
var str = `//
--
//
--`;
What we want to do is get all the '12' which at the begining of each line:
If we do like that:
var regex = /^/g;
To solve this problem, we can use 'm' flag:
var regex = /^/gm;
And also we want to get the line which end by '16':
var regex = /^.+$/gm;