maryj Posted August 29, 2011 Share Posted August 29, 2011 I need help creating a FP rule that will go from the right and at the first comma add a space and the word "and", but not change any of the other commas if there are any. Is it possible to do this and if it is, can you tell how the rule would be? Thanks! Link to comment Share on other sites More sharing options...
Andre Globensky Posted August 29, 2011 Share Posted August 29, 2011 Try this. Change the string between quote to your field (var lcString = Field("xyz")) var lcString = "Looking for, the last comma, of string" var lnPosition = lcString.lastIndexOf(",") var part1 = Trim(lcString.substring(lnPosition ,-1)); var part2 = Trim(lcString.substring(lnPosition + 1 )); return part1 + ' and ' + part2 Link to comment Share on other sites More sharing options...
Dan Korn Posted August 29, 2011 Share Posted August 29, 2011 return Field("YourFieldName").replace(/,([^,]*)$/, ", and$1"); Link to comment Share on other sites More sharing options...
maryj Posted August 29, 2011 Author Share Posted August 29, 2011 Thanks Dan, that worked great, but now I need it to do one more thing. I need that same rule to add a space after the other commas in the field. This is what is in the field: Home purchase/refinance,Business checking account,Business/commercial loans I need the rule to make it say: Home purchase/refinance, Business checking account, and Business/commercial loans Is this possible with one rule? Thanks, Mary Link to comment Share on other sites More sharing options...
Dan Korn Posted August 29, 2011 Share Posted August 29, 2011 I need that same rule to add a space after the other commas in the field. This is what is in the field: Home purchase/refinance,Business checking account,Business/commercial loans I need the rule to make it say: Home purchase/refinance, Business checking account, and Business/commercial loans Is this possible with one rule? return Field("YourFieldName").replace(/,([^,]*)$/, ",and $1").replace(/,/g, ", "); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.