Is there any online regex tool to create regular expressions for given sample data ?
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'
RegexGenerator++ generates a regular expression starting from given data.
As a regular expression generator (log entry as input, regex as output) you can also use the one under:
It provides a generic regex with URLs, IPs, ports, usernames and so on parsed at some extent.
The other sites were great for testing, but this one builds a RegEx from your Index data. Very helpful, thanks!
My favourite is: http://www.rubular.com
Fast and interactive
This is online tool: http://www.regexr.com/
This is cool interactive tutorial: http://regexone.com/ (20 exercises)
I belive the best tool for the job is ;
regex101.com .
Simply superb!!
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
The Field Extractor app is useful sometimes. Have a look.
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