Regular expression replacing only if contained withing a regular expression match?
Posted
by Tower
on Stack Overflow
See other posts from Stack Overflow
or by Tower
Published on 2010-05-21T05:56:58Z
Indexed on
2010/05/21
6:10 UTC
Read the original article
Hit count: 215
Hi,
I have the following:
[list]
[*] test
[*] test
[*] test
[/list]
and I would like to create a regular expression that turns that into:
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
I know regex enough to replace simple tags, but in this case I need to replace li tags only if they are contained inside ul. Is there a way to check that before replacing?
I am using JavaScript if that matters.
© Stack Overflow or respective owner