0

I have a character set {x, y, z} and I want to check if some string contains at least one character from this set.
For example:

abxyz - valid
zabc1 - valid
abc4e - not valid
animuson
  • 53,861
  • 28
  • 137
  • 147
Islam Sabyrgaliyev
  • 340
  • 1
  • 5
  • 10

2 Answers2

3

/.*[xyz].*/ should do the trick

icke
  • 1,568
  • 1
  • 19
  • 31
  • +1 for specifying set of discrete values rather than range. Range works for the given example, but the values in an arbitrary set may not be sequential. – Tiksi Jan 10 '13 at 12:35
1

Try this regex:

.*[x-z].*

This will only match lines that include [x-z] at least once.

Example

Cerbrus
  • 70,800
  • 18
  • 132
  • 147