I would like to replace newline char as "<BR>" and whitespace at the begining of each line as "&nbsp;". This is my pattern string: "/\r\n\s*/i" and I don't understand why this didn't work. It suppose to match all \r\n with (if any) whitespace after that. Please help with my pattern string.