-1

i'm having a regex that is allowing only Latin letters and numbers and allows the symbols @, _ and .. The final requirement is that it must contain at least one Latin letter.

My regex is this:

const regTest = /^([0-9A-Za-z_@.])+$/g;
melpomene
  • 84,125
  • 8
  • 85
  • 148
RamAlx
  • 6,976
  • 23
  • 58
  • 106

2 Answers2

2

You can try with following regex:

/^[0-9a-z_@.]*[a-z][0-9a-z_@.]*$/i
hsz
  • 148,279
  • 62
  • 259
  • 315
2

You may also try with the usage of positive lookahead:

^(?=.*[a-z])[\w@\.]*$

Use with ignore case flag.

Demo

Community
  • 1
  • 1
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56