Hi,
I have a regular expression that converts newline characters to '<BR>'. I need to modify this so that it only converts the newline characters if they are not preceeded by certain other strings ('table>', 'td>' and 'tr>')
So, examples would be as follows:
original string:
'line1\n line2\n line3'
would be converted to:
'line1<BR> line2<BR> line3'
Whereas:
'<table>\n<tr>\<td>line1\nline2\nline3</td>\n</tr>\n</table>'
would be converted to:
'<table>\n<tr>\<td>line1<BR>line2<BR>line3</td>\n</tr>\n</table>'
My existing expression is:
$foo =~ s/\n/<BR>/g;
which converts ALL occurrences of \n. If any regex gurus out there can let me know the trick to ignore \n preceeded by 'table>', 'td>' and 'tr>' (I've left the opening bracket off in order to catch both openng and closing tags) then I'd be extremely grateful.
Cheers,
Nick Roper
I have a regular expression that converts newline characters to '<BR>'. I need to modify this so that it only converts the newline characters if they are not preceeded by certain other strings ('table>', 'td>' and 'tr>')
So, examples would be as follows:
original string:
'line1\n line2\n line3'
would be converted to:
'line1<BR> line2<BR> line3'
Whereas:
'<table>\n<tr>\<td>line1\nline2\nline3</td>\n</tr>\n</table>'
would be converted to:
'<table>\n<tr>\<td>line1<BR>line2<BR>line3</td>\n</tr>\n</table>'
My existing expression is:
$foo =~ s/\n/<BR>/g;
which converts ALL occurrences of \n. If any regex gurus out there can let me know the trick to ignore \n preceeded by 'table>', 'td>' and 'tr>' (I've left the opening bracket off in order to catch both openng and closing tags) then I'd be extremely grateful.
Cheers,
Nick Roper