Splunk Search

Is there any online regex tool to create regular expressions for given sample data ?

splunker12er
Motivator

Is there any online regex tool to create regular expressions for given sample data ?

Tags (1)

ravikharatmal
New Member

If you want to build regex using plain simple English for your sample data & test matches also then you can use https://itsallbinary.com/simply-regex/regex-builder-tool

You can simply use plain English phrases from auto suggestions & tool will generate regex for it. You can also test generated regex right there with your sample data as asked in question. One example of capturing log statement from this tool -

_Match_anywhere_in_text_ _any_digit_ _then_ _exact_string_ ( /) _then_ _any_digit_ _then_ _exact_string_ ( /) _then_ _one_or_more_of_ ( _any_digit_) _then_ _any_whitespace_ _then_ _exact_string_ ( -) _then_ _any_whitespace_ _then_ _capture_this_ ( _one_or_more_of_ ( _as_less_as_possible_of_ _any_character_)) _then_ _any_whitespace_ _then_ _exact_string_ ( -) _then_ _capture_this_ ( _one_or_more_of_ ( _any_character_ )) _then_ _exact_string_ ( -) _then_ _capture_this_ ( _one_or_more_of_ ( _any_character_))

This generates complex regex: \d\/\d\/(?:\d)+\s\-\s((?:.)+?)\s\-((?:.)+)\-((?:.)+)

You can also test with your sample data: 6/7/2020 - MyClass - Today is Sunday and yesterday was Saturday - Success

It will match regex with your sample data & show groups:

Full Match = '6/7/2020 - MyClass - Today is Sunday and yesterday was Saturday - Success'
Group 1 = 'MyClass'
Group 2 = ' Today is Sunday and yesterday was Saturday '
Group 3 = ' Success'

 

0 Karma

markall
New Member

RegexGenerator++ generates a regular expression starting from given data.

0 Karma

mihnea
Engager

As a regular expression generator (log entry as input, regex as output) you can also use the one under:

http://regex.logxtender.net

It provides a generic regex with URLs, IPs, ports, usernames and so on parsed at some extent.

SAF_IT
Engager

The other sites were great for testing, but this one builds a RegEx from your Index data. Very helpful, thanks!

0 Karma

mikaelbje
Motivator

My favourite is: http://www.rubular.com

Fast and interactive

dimoobraznii
Path Finder

This is online tool: http://www.regexr.com/
This is cool interactive tutorial: http://regexone.com/ (20 exercises)

lmyrefelt
Builder

I belive the best tool for the job is ;

regex101.com .

Simply superb!!

dwaddle
SplunkTrust
SplunkTrust

If you like Regex101 (and I do), but cannot reach it from a customer site or are concerned about sending private data to the internet you can run it offline using a trick from https://github.com/Syskaw/Regex101.com-offline-app/blob/master/runLocalRegex101.sh

somesoni2
Revered Legend

The Field Extractor app is useful sometimes. Have a look.

http://apps.splunk.com/app/494/

tom_frotscher
Builder

There are tools available where you can test your created regex. They also provide short documentation for the most common regex tokens. For example here: link

Also Splunk on his own has the ability to create a regex expression based on examples. Read more here: link

RiccardoV
Communicator

I think that it is more a Stack Overflow question, it isn't so much related to Splunk 🙂

BTW, you can take a look here: http://www.txt2re.com/index.php3

.conf21 Now Fully Virtual!
Register for FREE Today!

We've made .conf21 totally virtual and totally FREE! Our completely online experience will run from 10/19 through 10/20 with some additional events, too!