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
  • 50,765
  • 27
  • 132
  • 142

2 Answers2

3

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

icke
  • 1,528
  • 1
  • 18
  • 29
  • +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
  • 60,471
  • 15
  • 115
  • 132