Jump to content

conditional return rule


Recommended Posts

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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 + "$"), "");

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...