mIRC Home    About    Download    Register    News    Help

Print Thread
#167678 28/12/06 07:54 PM
K
klaaamp
klaaamp
K
I just want to match by|apple|orange
It should only be one of those word and nothing else before or after the letters, what is the right regex for this?

#167679 28/12/06 08:09 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Code:
/^(?:by|apple|orange)$/i

b1ink #167680 28/12/06 08:25 PM
K
klaaamp
klaaamp
K
sure that works? seems not when I try it in mirc or regexbuddy

#167681 28/12/06 08:29 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Not sure. but I guess you asked for several words match? like istok?

post example please.

b1ink #167682 28/12/06 08:34 PM
K
klaaamp
klaaamp
K
$regex(by,
it should only match that or if its $regex(apple, etc,
$regex(apple.anythingelse, or $regex(jkjfsapple, shouldnt be matched.

b1ink #167683 28/12/06 08:43 PM
Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
Code:
/\b(?:by|apple|orange)\b/i


Will match the words "by", "apple", or "orange", as they might appear in a sentence (ie. it will match them even if they appear next to punctuation).

#167684 28/12/06 09:01 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
I think you asked the same question before. read this thread all you have to do is to remove the \. and insert your words.

b1ink #167685 28/12/06 09:45 PM
K
klaaamp
klaaamp
K
Originally Posted By: b1ink
I think you asked the same question before. read this thread all you have to do is to remove the \. and insert your words.


Tried that, but it didnt work, it will only match apple if its starts with it w/o anything before but if it is followed by other words or dots it will also match and it shouldnt

#167686 28/12/06 09:55 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Ok then. Use star_bucks's pattern.

b1ink #167689 28/12/06 10:40 PM
K
klaaamp
klaaamp
K
Originally Posted By: b1ink
Ok then. Use star_bucks's pattern.

His pattern have same problem as yours but both ways, add a dot or a dot after "by", like $regex(by., or $regex(.by, and it will also match and I dont want that..

Last edited by klaaamp; 28/12/06 10:41 PM.
#167701 29/12/06 02:21 AM
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
$regex(%text,/(?:\s|^)(by|apple|orange)(?:\s|$)/i)

Will match one of those three words (by, apple, orange) as long as it is surrounded by a space character (space, tab) or the beginning or end of the string.

-genius_at_work

#167738 29/12/06 08:08 AM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Use all pattern given within this thread and see if one of them works!!
Code:
/(?<=^| )(?:by|apple|orange)(?= |$)/ig


Link Copied to Clipboard