On 2/9/06, ibiza <lambertb gmail.com> wrote:
>
> -------------------------------------------
>
> Would it be simple with regular expression to transform
the list formed
> of hyphens("-") to an HTML unordered list?
What are you using to build the website? Regex can do the
find/replace part, it's just a matter of knowing how to use
the regex
libraries in the scripting language you're using. In php,
you'd want
to use the preg functions.
Really all you'd have to do is build a function that takes a
list in
hyphen format and returns it as html. For example
function listMarkup($list) {
$output = "<ul>n";
$output .= preg_replace('#$-
(.*?)$#im','<li>$1</li>',$list);
$list.="</ul>n";
return $output;
}
Then all you have to do is run that function over each of
your lists,
which could be done by passing the entirety of your text
through like
this
$text = preg_replace('#(?:(^-
.*?)[\r\n]){2,}#ime','listMarkup($0)',$text);
Note the 'e' modifier in the regex, it's necessary to pass a
function
over the results directly as I did there.
I haven't actually tested this for accuracy, but it should
at least
give you an idea ;)
--
Remember, no matter where you go, there you are. -Buckaroo
Banzai
|