Splunk Search

Field extracting using Regex

satishsdange
Builder

I am trying to extract username & password from below event -

form_key=6LgmjzGyzOYLIf11&login[username]=dev_lee@gmail.com&login[password]=password&send= 

I am able to extract password properly but for username I am getting dev_lee%40gmail.com instead of precise email ID.
Below is my regex

login.*?username.*?=(?<splUsername>.*?)&.*?login.*?password.*?=(?<splPassword>.*?)&

Could someone please help me fix the problem.

Tags (1)
0 Karma
1 Solution

esix_splunk
Splunk Employee
Splunk Employee

Try this in addition to the urldecode..

.. | rex field=_raw "login\[username\]\=(?<username>[^\&]+)\&login\[password\]\=(?<password>[^&]+)\&send" | eval mail=urldecode(username) | ..

That should fix you up.

View solution in original post

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

Try this in addition to the urldecode..

.. | rex field=_raw "login\[username\]\=(?<username>[^\&]+)\&login\[password\]\=(?<password>[^&]+)\&send" | eval mail=urldecode(username) | ..

That should fix you up.

0 Karma

Sebastian2
Path Finder

Looks like your event is url encoded. Have you tried to decode it? Try using the buildin urldecode?
When searching your data you could use it like:

... | eval mail = urldecode(mail) | ...
Get Updates on the Splunk Community!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...