MySQL Forums
Forum List  »  InnoDB

Regex first three octets
Posted by: alfonso caponi
Date: October 20, 2008 06:37AM

Hi,

I've a column with ip address. How can I extract only the first three octets
(for example 127.0.0)?

select ip from tbl_hosts where ip REGEXP '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}';

This query is wrong because extract all four octets.

Thank you very much,
Al

Options: ReplyQuote


Subject
Views
Written By
Posted
Regex first three octets
5820
October 20, 2008 06:37AM
2837
October 20, 2008 08:08AM
2841
October 20, 2008 08:58AM
2937
October 21, 2008 03:32AM
5746
December 01, 2008 05:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.