I have a string like this:
var str = "this is test1
this is test2
this is test3";
Now I want if both sides of that range are \n then returns true, else return false. In the above example just these three ranges are true:
[0 - 12] => true
[14 - 26] => true
[27 - 39] => true
And all other ranges have to be false. Like these: [1 - 12], [5 - 17], ...
Note: Spaces before and after that range doesn't matter. For example:
var str = " this is a test ";
Now this ranges are true: [0 - 20], [2 - 18], [5 - 22], ...
In reality, I'm trying to create a markdown-editor and now I'm working on its code-method button. So I need to know, if all of selected text (that range) is in a line, then append 4spaces before it, else append two "`" surround it.