Following on from my earlier question I’ve been experimenting with the post-function functionality. I’m extracting a block of text but want to remove blank lines. Phil provided a snippet of JavaScript to replace multiple “<br />” with a single one.
What I’m trying to do now is remove ANY that occur at the start of the string. The text extracted is “<br />The Owner<br />of a prop<br /><br />”.
The caret is the normal method of anchoring the comparison to the beginning of the string but I can’t get it to work. My post-function reads replace(/^<br />/,“”); If I remove the caret it removes the 1st occurrence so I’m thinking I must have an error in my caret.
Odd isn’t it. For days now I’d been struggling with this. Come in this morning, type in a regexp and it worked! I’d ended up with replace(/(\s+)|(){2}/g,“”).replace(/^/,“”);
The first replace gets rid of white spare and double and the second replace removes any from the start. Might not be pretty but it works!