toddvoros
asked on
How to have Regular expression keep first 14 characters and start changes at character 15 or beyond
I need a regular expression that keeps the first 14 characters of a string intact with no changes. However, if there is a hypen in character 15 or beyond, remove the hypen and all text past the hypen. If the string is 14 characters or less, do nothing.
Any help on this is greatly appreciated.
Any help on this is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/(\d{14})(\-.*)?/
You can test it in this amazing tool:
https://regex101.com/r/kP0