Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who has the algorithm of translating RegExp into "natural language"?

Tags:

regex

I want to "translate" a regular expression into a human-readable explanation.

For example: /^[a-z0-9_]{6,18}/ will be translated to something like:

A string start with 6 to 18 char(s) in a range of a to z, 0 to 9 and _.

like image 790
user1164522 Avatar asked Jan 23 '12 08:01

user1164522


People also ask

What algorithm is used with regex?

Most library implementations of regular expressions use a backtracking algorithm that can take an exponential amount of time on some inputs.

Is regex a Natural Language Processing?

They form part of the basic techniques in NLP and learning them will make you a more efficient programmer. Therefore, Regular Expression is one of the key concepts of Natural Language Processing that every NLP expert should be proficient in.

Why regex is important in NLP?

Regular Expressions RE helps us to match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are used to search texts in UNIX as well as in MS WORD in identical way. We have various search engines using a number of RE features.

What does regexp stand for?

Regular Expressions (Regex) Regular Expression, or regex or regexp in short, is extremely and amazingly powerful in searching and manipulating text strings, particularly in processing text files. One line of regex can easily replace several dozen lines of programming codes.


2 Answers

Expresso, a free tool, does this (and does a good job too).

Expresso 3.0 on Microsoft's regular expression Webcast series

like image 58
Mitch Wheat Avatar answered Oct 17 '22 18:10

Mitch Wheat


Using RegexBuddy (Paid however in my opinion the best tool available) the expression is documented as below:

// ^[a-z0-9_]{6,18}
// 
// Options: ^ and $ match at line breaks
// 
// Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
// Match a single character present in the list below «[a-z0-9_]{6,18}»
//    Between 6 and 18 times, as many times as possible, giving back as needed (greedy) «{6,18}»
//    A character in the range between “a” and “z” «a-z»
//    A character in the range between “0” and “9” «0-9»
//    The character “_” «_»

The tool also allows you to select a line in the documentation and showing you the part in the regular expression.

Sample of the documentation feature

like image 41
Myrtle Avatar answered Oct 17 '22 18:10

Myrtle