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

有帮助吗?

解决方案 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)/

其他提示

Using negative lookahead:

>> 'status: inactive ' =~ /(?!.*(disabled|inactive))^/
=> nil
>> 'status: disabled' =~ /(?!.*(disabled|inactive))^/
=> nil
>> 'status: enabled' =~ /(?!.*(disabled|inactive))^/
=> 0
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top