-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
  • 81,915
  • 7
  • 76
  • 137
user7334203
  • 6,006
  • 20
  • 46
  • 97

2 Answers2

2

You can try with following regex:

/^[0-9a-z_@.]*[a-z][0-9a-z_@.]*$/i
hsz
  • 143,040
  • 58
  • 252
  • 308
2

You may also try with the usage of positive lookahead:

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

Use with ignore case flag.

Demo

Community
  • 1
  • 1
NeverHopeless
  • 10,869
  • 4
  • 34
  • 55