Splunk Search

regular expression to find special character

logloganathan
Motivator

I want to use regular expression which should get special charcter in Splunk
Please help in this

0 Karma
1 Solution

niketn
Legend

@logloganathan, based on the sample Data provided can you try the following:

 <yourBaseSearch>
 | rex field=_raw "(?<special_character>[^\w|\s]+)"

Following is the link to regex to test with your sample data: https://regex101.com/r/9K4Ugs/1

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@logloganathan, based on the sample Data provided can you try the following:

 <yourBaseSearch>
 | rex field=_raw "(?<special_character>[^\w|\s]+)"

Following is the link to regex to test with your sample data: https://regex101.com/r/9K4Ugs/1

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

logloganathan
Motivator

thanks for your answer..Could you please post the same in answer box

0 Karma

niketn
Legend

@logloganathan, I have converted my comment to answer. Please accept to mark this question as answered 🙂

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketn
Legend

@logloganathan, please add a sample event and provide the details of which field you want to extract. As you might already know that regular expressions are very much pattern based and without sample/mocked up data it would be tough to assist. You should anonymize (so that pattern for regular expression remains the same) any sensitive data before posting the same.

You can always use tools like regex101.com to add sample data and test your own regular expressions.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

logloganathan
Motivator

sargünan ramesh where u is not normal
i want to get the word sargünan when it finds letter ü
similarly Tamil şangam where S is not normal but i want the word şangam to be displayed in output

0 Karma

logloganathan
Motivator

any update?

0 Karma

logloganathan
Motivator

Sure let me give the sample..

0 Karma

493669
Super Champion

use backslashes \ before special character in regex.

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!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...