I need a regex to check the conditions below,
1) include - (dash) and _ (underscore) as valid components.
2) cannot end with (dash) and (underscore).
Im using this - ^[A-Za-z0-9]+([-_]+[A-Za-z0-9]+)*$but not sure how to include the second condition, i.e. can't end with a dash or underline
source
share