I have a textarea in which I need to validate that at least one line contains ** at the beginning of it.
Examples
Line 1
Line 2
Line 3
INVALID
Line 1
**Line 2
Line 3
VALID
**Line 1
Line 2
**Line 3
VALID
Is this possible using Regex?
Thanks开发者_StackOverflow中文版 in advance,
Marko
/^\*\*/m.test(textareaEl.value)
The m
flag means multi-line mode. In that mode, ^
matches the beginning of the string, and the beginning of each line. We have to escape * as \*
.
精彩评论