I
ibiza
Hi all,
I have a question which I have no ideal of the answer...I am currently
working on a web application and at some time, I have a string
representing a short text. This could be a simple example :
"This is my list :\n\r-list item 1\n\r-list item 2\n\r-list item
3\n\r\n\rThis was a great list."
Let's say this outputs like that :
-------------------------------------------
This is my list :
-list item 1
-list item 2
-list item 3
This was a great list.
-------------------------------------------
Would it be simple with regular expression to transform the list formed
of hyphens("-") to an HTML unordered list? I mean that the preceding
example would rather output as :
-------------------------------------------
This is my list :
<ul><li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li></ul>
This was a great list.
-------------------------------------------
I have some experience with regular expression but have not a clue on
how to do this...I also see some problems as if the string starts with
an hyphen, as it would also need to transform correctly, event if it
doesn't have the /n/r before the hyphen("-").
e.g. "-list item 1/n/r- list item 2" should output as :
-------------------------------------------
<ul><li>list item 1</li>
<li>list item 2</li><ul>
-------------------------------------------
And what about if there are two lists separated by some carriage
returns?...As you can see, I really don't know where to start with this
problem. :/
Thanks in advance,
ibiza
I have a question which I have no ideal of the answer...I am currently
working on a web application and at some time, I have a string
representing a short text. This could be a simple example :
"This is my list :\n\r-list item 1\n\r-list item 2\n\r-list item
3\n\r\n\rThis was a great list."
Let's say this outputs like that :
-------------------------------------------
This is my list :
-list item 1
-list item 2
-list item 3
This was a great list.
-------------------------------------------
Would it be simple with regular expression to transform the list formed
of hyphens("-") to an HTML unordered list? I mean that the preceding
example would rather output as :
-------------------------------------------
This is my list :
<ul><li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li></ul>
This was a great list.
-------------------------------------------
I have some experience with regular expression but have not a clue on
how to do this...I also see some problems as if the string starts with
an hyphen, as it would also need to transform correctly, event if it
doesn't have the /n/r before the hyphen("-").
e.g. "-list item 1/n/r- list item 2" should output as :
-------------------------------------------
<ul><li>list item 1</li>
<li>list item 2</li><ul>
-------------------------------------------
And what about if there are two lists separated by some carriage
returns?...As you can see, I really don't know where to start with this
problem. :/
Thanks in advance,
ibiza