Alex Rivera | Logout

RegEx for a string to NOT contain two different strings

Asked 2010-01-28T23:44:54.287
9

Ok you gurus out there who know Regex!

How do you use reg ex to search a string to make sure it doesn't contain either of two different strings.

Example: Say i want to make sure "FileNTile" doesnt contain File or Tile

Thanks

cnorr

Edit
Report

1 Answer

0

It depends on the language. Easiest way (conceptually): search for both, and make sure both fail to match. In Ruby:

s = "FileNTile"
(s !~ /File/) and (s !~ /Tile)  # true if s is free of files and tiles.
answered 2010-01-28T23:47:40.840

Your Answer