私は、apple-juice
があなたのパラメータに従って一致するはずですが、apple juice
はどうですか?私はあなたがまだapple juice
を検証しているなら、あなたはまだそれが失敗したいと思っています。 「単語の境界」ではなく「単語文字」の標準リストとして\b
カウントdoesnのほとんどの正規表現の風味で
/[^-a-z0-9A-Z_]/ // Will match any character that is <NOT> - _ or
// between a-z 0-9 A-Z
/(?:^|[^-a-z0-9A-Z_])/ // Matches the beginning of the string, or one of those
// non-word characters.
/(?:[^-a-z0-9A-Z_]|$)/ // Matches a non-word or the end of string
/(?:^|[^-a-z0-9A-Z_])(apple|orange|juice)(?:[^-a-z0-9A-Z_]|$)/
// This should >match< apple/orange/juice ONLY when not preceded/followed by another
// 'non-word' character just negate the result of the test to obtain your desired
// result.
」: -
だから「境界」としてカウント文字のセットを構築することができますtには-
が含まれていますので、カスタムを作成する必要があります。あなたにも-
をキャッチしようとしていなかった場合にのみ、「一単語」テストをテストしている場合、それはあなたがはるかに簡単に行くことができます
... /\b(apple|orange|juice)\b/
と一致する可能性:
/^(apple|orange|juice)$/ // and take the negation of this...
あなたはどの言語で作業していますか?また、 "オレンジジュース"と一致するか、失敗する必要がありますか? – gnarf