Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need a RegEx tool that suggests expressions based on selected text [closed]

Tags:

regex

I've found several online tools that allow me to see the effect of a regular expression I have created on sample text, but I am looking for a tool that would make expression suggestions based on a portion of text selected.

For Example:

Let's say I have a string like this,

obssoCookie=set-usermember1-404343994;Version=1;Path=/;Domain=10.118.195.239;Discard

and I want to extract everything between obssoCookie= and the first ; I'd like a tool that would allow me to select that part of the text and respond with a suggested regular expression.

like image 833
urbanaut Avatar asked Jun 02 '11 20:06

urbanaut


People also ask

What does '$' mean in regex?

$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.

What is regex tool in Alteryx?

Regular expressions, most commonly referred to as RegEx (pronounced: Rej-Ex), are a sequence of characters that allows the user to create patterns that help match, locate, and manage any string data. In Alteryx, you can use the RegEx tool to replace, tokenize, parse, and match string values.

How do you create expressions in regex?

If you want to match for the actual '+', '. ' etc characters, add a backslash( \ ) before that character. This will tell the computer to treat the following character as a search character and consider it for matching pattern. Example : \d+[\+-x\*]\d+ will match patterns like "2+2" and "3*9" in "(2+2) * 3*9".

What is difference [] and () in regex?

[] denotes a character class. () denotes a capturing group. [a-z0-9] -- One character that is in the range of a-z OR 0-9. (a-z0-9) -- Explicit capture of a-z0-9 .


2 Answers

Check out txt2re.

Using your sample text, with the relevant portions selected, and C# selected for the code to be generated, this is the result.

It takes some getting used to, but the basic steps are:

  1. Select the link for individual characters or whole words desired based on the colored boxes generated on the page.
  2. Select the desired language.
  3. The pattern is built up for you in the generated sample code.
like image 102
Ahmad Mageed Avatar answered Dec 13 '22 04:12

Ahmad Mageed


I found this recently, uses genetic algorithm to find best matching pattern given a few examples that you generate yourself:

http://regex.inginf.units.it/

like image 26
mmagician Avatar answered Dec 13 '22 06:12

mmagician