Jump to content

Extend Text and Remove Text After Comma


Recommended Posts


I am trying to create one rule that does the following two things:

  • I would like the rule to remove everything after the comma and the comma itself
  • VP to change to Vice President & AVP to Assistant Vice President

Example Text:

VP, Creative Manager

AVP, Digital Media Specialist


Vice President

Assistant Vice President

Link to comment
Share on other sites

var s = "AVP, Digital Media Specialist";
return s.split(',')[0].replace(/(A?)(VP)/, function(m, A, VP) { return (A ? "Assistant " : "") + "Vice President"; } )


var s = "AVP, Digital Media Specialist";
var result = s.split(',')[0];
var parts = result.match(/(A?)(VP)/);
if (parts)
    result = (parts[1] ? "Assistant " : "") + "Vice President";

return result;


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