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
  • 52,378
  • 28
  • 138
  • 145
Islam Sabyrgaliyev
  • 300
  • 1
  • 5
  • 9

2 Answers2

3

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

icke
  • 1,558
  • 1
  • 18
  • 30
  • +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
  • 65,559
  • 18
  • 128
  • 140