Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Hive to extract multiple ip addresses from a string

avatar
Expert Contributor

Hi All,

I have a string

String:
some text with an ip 111.111.111.111 and a decimal 11.2323232 and some text here and then an int 1 and then some HTTP/1.1 with a 503 request and then another ip 222.222.222.222 and some imaginary 999.999.999.999

I want to output all the ip addresses in comma saperated. I tried the below

select regexp_replace(regexp_replace(String,'[^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})]',' '),'\\s+',',');
+------------------------------------------------------------------------+--+
|                                  _c0                                   |
+------------------------------------------------------------------------+--+
| ,111.111.111.111,11.2323232,1,1.1,503,222.222.222.222,999.999.999.999  |
+------------------------------------------------------------------------+--+

Expected output is : 111.111.111.111,222.222.222.222,999.999.999

Could you please help me

1 ACCEPTED SOLUTION

avatar

Are you familiar with user defined functions?

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

@Shu can you please help me

avatar

Are you familiar with user defined functions?