AngelBenitez Posted July 18, 2023 Posted July 18, 2023 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
Dan Korn Posted July 19, 2023 Posted July 19, 2023 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
AngelBenitez Posted July 19, 2023 Author Posted July 19, 2023 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
AngelBenitez Posted July 19, 2023 Author Posted July 19, 2023 Hello @Dan Korn, thank you so much for your help. I really appreciate it. Quote
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.