Help with REGEXP
I am trying to pick out a range of IP addresses using REGEXP but failing miserably :) The pattern I want to match is: 10.%.224-239.%.% The regex I have looks like this: AND INET_NTOA(src_ip) REGEXP '\d{1,3}\\.\d{1,3}\.(22[4-9]|23[0-9])\\.\d{1,3}' but, go fish. Thoughts? Thanks! -- Paul Halliday http://www.pintumbler.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: Help with REGEXP
Paul, You could look for a tool called The Regex Coach. While it is mainly for Windows, it runs very well in vine. I fijd it highly useful to debug regexps. Best regards, Olivier -- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: Help with REGEXP
Trying to pattern match ip addresses is a famous anti-pattern; it's one of those things like you feel like it should work, but it won't. Your case, however, is pretty specific. taking advantage of the limited range (I will assume you only wanted 4 sections of IPv4) this should come close: 10[.]\d{1,3}[.](224|225|226|227|228|229|23\d))[.]\d{1.3} On Thu, Mar 19, 2015 at 9:39 AM, Paul Halliday paul.halli...@gmail.com wrote: I am trying to pick out a range of IP addresses using REGEXP but failing miserably :) The pattern I want to match is: 10.%.224-239.%.% The regex I have looks like this: AND INET_NTOA(src_ip) REGEXP '\d{1,3}\\.\d{1,3}\.(22[4-9]|23[0-9])\\.\d{1,3}' but, go fish. Thoughts? Thanks! -- Paul Halliday http://www.pintumbler.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql -- - michael dykman - mdyk...@gmail.com May the Source be with you.
Re: Help with REGEXP
I don't think it accepts \d, or much of anything else I am used to putting in expressions :) This is what I ended up with and it appears to be working: REGEXP '10.[[:alnum:]]{1,3}.(22[4-9]|23[0-9]).[[:alnum:]]{1,3}' On Thu, Mar 19, 2015 at 11:10 AM, Michael Dykman mdyk...@gmail.com wrote: Trying to pattern match ip addresses is a famous anti-pattern; it's one of those things like you feel like it should work, but it won't. Your case, however, is pretty specific. taking advantage of the limited range (I will assume you only wanted 4 sections of IPv4) this should come close: 10[.]\d{1,3}[.](224|225|226|227|228|229|23\d))[.]\d{1.3} On Thu, Mar 19, 2015 at 9:39 AM, Paul Halliday paul.halli...@gmail.com wrote: I am trying to pick out a range of IP addresses using REGEXP but failing miserably :) The pattern I want to match is: 10.%.224-239.%.% The regex I have looks like this: AND INET_NTOA(src_ip) REGEXP '\d{1,3}\\.\d{1,3}\.(22[4-9]|23[0-9])\\.\d{1,3}' but, go fish. Thoughts? Thanks! -- Paul Halliday http://www.pintumbler.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql -- - michael dykman - mdyk...@gmail.com May the Source be with you. -- Paul Halliday http://www.pintumbler.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql