Jump to content

Line Break Placement


CrestGraphics

Recommended Posts

Trying to put together a postcard. Some of the names have just the last name, and some have "Lastname and family." I'd like the "and family" bit to drop to the next line. I saw there was a rule that worked with a hyphenated last name, but couldn't seem to make it work with "and."

 

screenshot:

http://img515.imageshack.us/img515/6219/screenshot20130213at737.png

Link to comment
Share on other sites

var s = Field("Your Field");
s.replace("and","<br>and");
return s;

That's not quite right. For one thing, you have to assign the result of the String.replace call back the string, like so:

s = s.replace("and", "<br>and");

Or just return the result of the call, like so:

return s.replace("and", "<br>and");

But there's another problem too. You need to be careful about what you're replacing. You don't want to turn a name like "Russell Brand" into "Russell Br<br>and". I would use the "\b" (word boundary) escape in a regular expression to make sure you're only modifying complete words, like so:

return s.replace(/\band\b/, "<br>and");

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.

Guest
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...