mIRC Home    About    Download    Register    News    Help

Print Thread
#167678 28/12/06 07:54 PM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
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?

klaaamp #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


Kind Regards, blink
b1ink #167680 28/12/06 08:25 PM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
sure that works? seems not when I try it in mirc or regexbuddy

klaaamp #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.


Kind Regards, blink
b1ink #167682 28/12/06 08:34 PM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
$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,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
klaaamp #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.


Kind Regards, blink
b1ink #167685 28/12/06 09:45 PM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
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

klaaamp #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.


Kind Regards, blink
b1ink #167689 28/12/06 10:40 PM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
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.
klaaamp #167701 29/12/06 02:21 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
$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

klaaamp #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


Kind Regards, blink

Link Copied to Clipboard