Jump to content

Text replacement during run


rpaterick

Recommended Posts

var LName = Field("Last");
LName = LName.replace(" SR"," Sr").replace(" JR"," Jr").replace(" iii"," III").replace(" ii"," II");
return LName;

Note that I added a leading space for each version to lessen the chance of the code swapping out the letter combinations within an actual name.

Link to comment
Share on other sites

Note that I added a leading space for each version to lessen the chance of the code swapping out the letter combinations within an actual name.

Or you can use a regular expression to accomplish this, like so:

return Field("Last Name").replace(/\b[js]r\b/gi, function(w){return ToTitleCase(w);}).replace(/\bi+\b/gi, function(w){return ToUpper(w);});

Where \b in the reg ex denotes a word boundary.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...