I have this regex ^[a-zA-Z0-9*]+$ for only allowing alphanumeric chars and allow Asterisk(*). But I would like allow asterisk only at the start of the string. But asterisk is not allowed at the last 4 digits of the string.
- new RegExp('^[a-zA-Z0-9*]+$').test('test') ---Valid
- new RegExp('^[a-zA-Z0-9*]+$').test('test1234') --Valid
- new RegExp('^[a-zA-Z0-9*]+$').test('test@#_')--Invalid
- new RegExp('^[a-zA-Z0-9*]+$').test('****1234') --Valid
- new RegExp('^[a-zA-Z0-9*]+$').test('*tes**1234') --Valid
- new RegExp('^[a-zA-Z0-9*]+$').test('test****') --Should be Invalid
"How would I allow Asterisk only at the start of the string?" But if the asterisk presents in any of the last 4 positions then it should be invalid
*1*2345, for example?