开发者

REGEX - matching ** on at least one line in a textarea

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 \*.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜