CrestGraphics Posted February 13, 2013 Share Posted February 13, 2013 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 Quote Link to comment Share on other sites More sharing options...
step Posted February 13, 2013 Share Posted February 13, 2013 var s = Field("Your Field"); s.replace("and","<br>and"); return s; Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 13, 2013 Share Posted February 13, 2013 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"); 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.