मैंने देखा कि apple-juice
आपके पैरामीटर के अनुसार मेल खाना चाहिए, लेकिन apple juice
के बारे में क्या चाहिए? मुझे लगता है कि यदि आप apple juice
मान्य कर रहे हैं तो भी आप इसे विफल करना चाहते हैं।
/[^-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.
सबसे regexp जायके एक "शब्द सीमा" लेकिन के "शब्द अक्षरों" मानक सूची के रूप में गिना जाता है \b
नहीं करता है में ': -
तो है कि एक "सीमा" के रूप में गिना पात्रों का एक सेट का निर्माण करने देता टी -
शामिल हैं ताकि आपको एक कस्टम बनाने की आवश्यकता हो। यह /\b(apple|orange|juice)\b/
साथ मेल खा सकते हैं अगर आप -
रूप में अच्छी तरह पकड़ने की कोशिश कर नहीं कर रहे थे ...
आप केवल 'एक शब्द' परीक्षण परीक्षण कर रहे हैं, तो आप एक बहुत सरल के साथ जा सकते हैं:
/^(apple|orange|juice)$/ // and take the negation of this...
आप किस भाषा के साथ काम कर रहे हैं? "नारंगी का रस" मैच भी होना चाहिए, या असफल हो? – gnarf