By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

Need help creating regular expression for html lists...

P: n/a
I'm working on regular expressions to parse html tags into the wiki
syntax. i.e. for example, if i encounter text like - some <bmore </
btext, my regular expression should be able to convert that to some
'more' text. Simple things like the above, i was able to write but the
real problem lies when it comes to parsing lists and tables.

For example, i write down some text as follows -

# number one

# number two

# number three

i want to be able to convert that into html code -

<ol>

<li>number one</li>

<li>number two</li>

<li>number three</li>

</ol>

i was able to find out the first occurance and last occurance of #,
append a <olthere and get the number one/two/three within <li></li>.
So far so good...But the problem occurs when i have multiple lists on
the same page. Obviously, my search for the first and last occurance
of # will not be as desired as there are two lists in the page. i.e.

# number one

# number two

some text here

# number one

# number two

then unfortunately my parsing into html yields me

<ol>

<li>number one</li>

<li>number two</li>

some text here

<li>number one</li>

<li>number two</li>

</ol>

and not as

<ol>

<li>number one</li>

<li>number two</li>

</ol>

some text here

<ol>

<li>number one</li>

<li>number two</li>

</ol>

Can anybody help???

I'm trying out the above using VB.Net as well as javascript. So any
help in either of the languages is most welcome...

Mar 21 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.