开发者

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

开发者 https://www.devze.com 2023-01-05 08:52 出处:网络
I have a textarea in which I need to validate that at least one line contains ** at the beginning of it.

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

精彩评论

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

关注公众号