AngelBenitez Posted July 18 Share Posted July 18 Hello, 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 Output Vice President Assistant Vice President Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 19 Share Posted July 19 var s = "AVP, Digital Media Specialist"; return s.split(',')[0].replace(/(A?)(VP)/, function(m, A, VP) { return (A ? "Assistant " : "") + "Vice President"; } ) Or: 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; Quote Link to comment Share on other sites More sharing options...
AngelBenitez Posted July 19 Author Share Posted July 19 Hello @Dan Korn; thank you for your help. If the value is being pulled from an Excel sheet, what would be the rule to remove the variable in the Excel sheet? Quote Link to comment Share on other sites More sharing options...
AngelBenitez Posted July 19 Author Share Posted July 19 Hello @Dan Korn, thank you so much for your help. I really appreciate it. 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.