匹配子字符串但不是异常子字符串

Vis*_*hal 3 ruby regex

我有一些字符串:

new_account_notification
updated_account_notification
reactivated_account_notification
updated_billing_info_notification
Run Code Online (Sandbox Code Playgroud)

我想匹配这些字符串:

  • 应该包含 account
  • 但不应该包含 reactivated_account
  • 或者应该包含 billing_info

请建议正则表达式来满足这些条件.

Cas*_*yte 6

试试这种模式:

(?<!reactivated_)account|billing_info
Run Code Online (Sandbox Code Playgroud)

(?<!...) 是负面的看法(希望你的正则表达式支持它)

| 代表OR