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'
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.
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