Options
- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Solved
Go to solution
Hive to extract multiple ip addresses from a string
Labels:
- Labels:
-
Apache Hive
Expert Contributor
Created ‎02-06-2019 10:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Explorer
Created ‎02-07-2019 04:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you familiar with user defined functions?
2 REPLIES 2
Expert Contributor
Created ‎02-07-2019 04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Shu can you please help me
Explorer
Created ‎02-07-2019 04:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you familiar with user defined functions?
