Post

2 followers Follow
0
Avatar

take string from [ ] till \n

Hi, could you please kindly help?

At a text field I have a list of Supermenu checkboxes:

[x] 1

[ ] 2 

[ ] 3

I need to take the first line where checkbox is empty ([ ]) , from [ ] till the end of the line (\n).

So in my case the output should be "[ ] 2"

How should I do it?

Many thanks in advance!

Алексей Шильников

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Алексей,

var
text = @Multiline Text,
startIndex = (text.indexOf("[ ]")),
searchIndex = startIndex + text.substring(startIndex).indexOf("\n");
text.substr(startIndex,(searchIndex-startIndex))

Result is [ ] 2 (with 2 square brackets, not a check box)

Rainer

Rainer Grabowski 0 votes