regex challenge

Monkey Forums/Monkey Beginners/regex challenge

hub(Posted 2016) [#1]
Hi !

i'm searching a regex way to capture the text between the tags <TAG> and </TAG>

i've this : "<TAG>(.+?)<\/TAG>"

but not work with the carriage returns !

fsdfsdfdsfdsf
<TAG>i want you</TAG>
fdsfdsfsdf
dsfdsf
<TAG>
i
want
you
also
</TAG>
fsdfdsfdsf


( https://regex101.com for the tests ! )
Many thanks !


Pharmhaus(Posted 2016) [#2]
Hi,
The problem is that "." does not match newline by default.
Depending on what you are using you can turn this option on with the /s switch (single line mode).
See here (PCRE_DOTALL)
Javascript does not support it if I remember correctly and you need to use some other kind of workaround/hack instead.

EDIT:
In Javascript it is (?s)
See here

To make it work in the web add
gs
into the upper right modifier textfield next to the regex.


hub(Posted 2016) [#3]
Thanks !