Question

I want to test the web-element style: it shouldn't contain words "disabled" or "inactive".

Was it helpful?

Solution 2

Do you really need a "negative" regex? Why not create a regex that tests that it contains "disabled" or "inactive", and test for it to be false?

'status: inactive' !~ /(disabled|inactive)/

OTHER TIPS

Using negative lookahead:

>> 'status: inactive ' =~ /(?!.*(disabled|inactive))^/
=> nil
>> 'status: disabled' =~ /(?!.*(disabled|inactive))^/
=> nil
>> 'status: enabled' =~ /(?!.*(disabled|inactive))^/
=> 0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top