开发者

All valid words that must have even number of a's or even number of b's [closed]

开发者 https://www.devze.com 2023-01-30 11:29 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rheto开发者_运维技巧rical andcannot be reasonably answered in its current form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rheto开发者_运维技巧rical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

All valid words that must have even number of a's or even number of b's


I would recommend this site: http://rubular.com/. Its a sandbox for Regular Expressions where you can play around with them. It should help you solve your problem.


You cannot do this with one regular expression. For one word you'd need to do something like

if ((replace(/[^Aa]/g, "").length & 1) == 0)

Of course this highly depends on your programming language (the above would work in JavaScript)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号