REGEX - match ** at least one line in a text field

I have a text box in which I need to check 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

REALLY

**Line 1
Line 2
**Line 3

REALLY

Is this possible with Regex?

Thanks in advance,

Marco

+3
source share
1 answer
/^\*\*/m.test(textareaEl.value)

Flag mmeans multi-line mode. In this mode, it ^corresponds to the beginning of a line and the beginning of each line. We need to run away * like \*.

+4
source

Source: https://habr.com/ru/post/1752385/


All Articles