I have an odd situation in pulling info from a database to display a webpage.
The administrator copies and pastes info into a mediumtext latin1_swedish_ci
field (the description column).
There are • bullets in the data, not <li>
.
I am already doing a little formatting before displaying in Perl with:
my $string = $Description;
my @sentences = split(/(?:(?<=\.|\!|\?)(?<!Mr\.|Dr\.)(?<!U\.S\.A\.)\s+(?=[A-Z]))/, $string);
for (@sentences) {
#TRIED THIS $_ =~ s/•/<br />•/g;
print qq~ $_ <br /><br />~;
}
Which works pretty well making new lines after pe开发者_如何转开发riods. No complaints, yet.
However, the "bulleted" lists are all run together like List•foo•bar•nonewline
.
Obviously, I would like:
List
•foo
•bar
•nonewline
Is this possible? Does the old "garbage in, garbage out" rule kill this one?
I would just like to start a newline before the bullets. There is no HTML in the field and I have no control over that aspect. I can only control how it is displayed in the webpage in which HTML is obviously at my disposal.
Would HTML::FormatText be of any assistance here?
I appreciate verbose examples as I am very new to this. Thinking ahead, what if she pasted in different bullet types at times?
s/•/<br />•/g
Did you take a close look at the error message you got when you tried that? If you're using a slash as the delimiter in s///, then any slashes in the pattern or replacement will need to be escaped.
s/•/<br \/>•/g
But to make it more readable, use different delimiters.
s|•|<br />•|g
精彩评论