Splunk Search

How to edit my regular expression to extract these fields from my sample data?

dbcase
Motivator

Hi,

I have the below data

10.210.192.15 - - [12/Oct/2016:19:59:43 -0400] "GET /rest/icontrol/login?expand=sites,instances,points,functions HTTP/1.1" 401 6 "-" "Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG-SM-G920A Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.124 Mobile Safari/537.36"

10.210.192.5 - - [12/Oct/2016:19:50:06 -0400] "GET /rest/icontrol/login?expand=sites,instances,points,functions HTTP/1.1" 401 6 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Mobile/14A456"

And I'm trying to match on the OS for Android or the iPhone. I have this much of the regex (Android|iPhone) (?P<os>) but I'm now stumped as to what the remaining portion should be. I need to capture 6.0.1 from the first line and 10_0_2 from the second line.

0 Karma
1 Solution

somesoni2
Revered Legend

How about this

Updated

your base search | rex  "((Android)|(iPhone OS)) (?<os>[^\s\;]+)"

View solution in original post

0 Karma

aljohnson_splun
Splunk Employee
Splunk Employee
0 Karma

dbcase
Motivator

Hi,

Yes I'm already using that site but still stumped.

0 Karma

somesoni2
Revered Legend

How about this

Updated

your base search | rex  "((Android)|(iPhone OS)) (?<os>[^\s\;]+)"
0 Karma

lakromani
Builder

You do not need it inner parentheses, and you do not need to escape the ;, so this should do:

 your base search | rex  "(Android|iPhone OS) (?<os>[^\s;]+)"
0 Karma

dbcase
Motivator

BINGO!!!! Many thanks!!!!

0 Karma

dbcase
Motivator

Hey Somesoni2!

Close, that grabs the second line 10_0_2 but not the first line 6.0.1

0 Karma

somesoni2
Revered Legend

How about now?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...