The problem with this REGEX is that by default .
does not include \n
, this way it would have to get around this fault, it could be with deny [^...]
, which captures anything that is not in the group. p>
For your needs you can do this: <(textarea)([^>]*)>([^%]*?)</>
.
See working at REGEX101
Explanation
-
<(textarea)
- literally captures <
and generates a literal group with textarea
, which will be used as a shortcut.
-
([^>]*)>
- will be all attributes of the tag, remembering that attributes do not have >
so I used his negation to get everything, finally it should end with the term of tag >
.
-
([^%]*?)
- here is content to be captured, I have used the %
deny since I do not want to have this in the middle, but if you have just change to another character, for example ¬
, remembering that because it is Deny includes any and all characters that are not in the group including \n
.
-
</>
- finally must catch the end of the tag. which was resumed with the shortcut of the group 1
.
Addendum
You can also use the s
flag to allow .
(Dot) to capture \n
.
changing REGEX to <(textarea)([^>]*)>(.*?)</>
.
Remembering that% s of% should apply.
Example JS
string.match(/<(textarea)([^>]*)>(.*?)<\/>/gs); // aqui foi necessário escapar o '/', para não ser interpretado como fim da REGEX '<\/>'.
See working at REGEX101