oleooo Posted November 14, 2013 Share Posted November 14, 2013 I and trying to create a Rule that if text is present after the return it places a bullet point and if it is just a return then it is left blank but returned. if (Field("Bioandareaofinterest").indexOf("/<p>g/ textLines") > -1); return Field("Bioandareaofinterest").replace(/<p>/g, "<br>&bull< >"); if (Field("Bioandareaofinterest").indexOf("/<p>g/") > -1); return Field("Bioandareaofinterest").replace(/<p>/g); Quote Link to comment Share on other sites More sharing options...
esmith Posted November 14, 2013 Share Posted November 14, 2013 return Field("Bioandareaofinterest")replace(/<p>/g,"<br>• ").replace(/<br>• (?=\w*$)/,""); First replace exchanges all paragraph tags with a line break and a bullet/non-breaking space. Second replace removes the last break/bullet/space (previously exchanged) if it is not followed by anything. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 14, 2013 Share Posted November 14, 2013 I think this will work: var text = Field("Bioandareaofinterest"); return text.replace(/(<p>|<br>)(?!<p>|<br>)/g, "$1\n• ").replace(/\n• $/, ""); Or, more generally: var text = Field("Bioandareaofinterest"); var lineEndings = "<p>|<br>"; var linePrefix = "\n• "; return text.replace(new RegExp("(" + lineEndings + ")(?!" + lineEndings + ")", "g"), "$1" + linePrefix).replace(new RegExp(linePrefix + "$"), ""); Quote Link to comment Share on other sites More sharing options...
oleooo Posted November 15, 2013 Author Share Posted November 15, 2013 Thanks so much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.