views:

52

answers:

1

Hi everyone,

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 in advance,

Marko

+4  A: 
/^\*\*/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 \*.

Matthew Flaschen
Simply brilliant. Thank you Matthew!
Marko