Regex Runners

Paul Alexander edited this page Mar 24, 2015 · 6 revisions
Clone this wiki locally

Refiddle uses dialect specific runners to parse and highlight regular expressions and their corpus texts. Currently, refiddle knows only 3 dialects JavaScript, Ruby and .NET.

I need your help!

I'm looking for help building dialect runners for PHP, Perl, Python, Java or any other common Regular Expression system. Providing support for this is really easy, just provide a web service that responds to the following actions.

POST /evaluate

Matches the corpus text against the pattern and runs any corpus tests.

Form Data Description
pattern The regular expression. Either raw [a-z]* or literal /[a-z]*/ formats.
corpus_text The body of the corpus text to be matched against the pattern.

The service should return JSON like the following

{
  "10":[10,7],                // Match at index 10
  "name":[38,7],              // Named match at index 38
  "365": [365,13,"nomatch"],  // Corpus test failure
  "matchSummary": { 
    "total":2
  }
}

The results consist of several numbered or named matches whose value is an array of start index and length of the match, and for corpus tests, if the entry is a match or nomatch.

matchSummary is a summary of the match results

Field Description
total The total number of matches from the corpus text.
tests true/false if the corpus text includes tests.
passed The number of corpus tests that passed.
failed The number of corpus tests that failed.

POST /replace

Replace the matched patterns in corpus_text with replace_text.

Form Data Description
pattern The regular expression. Either raw [a-z]* or literal /[a-z]*/ formats.
corpus_text The body of the corpus text to be matched against the pattern.
replace_text The text to replace matched patterns with.

The service should return JSON like the following

{
  "replace" : "...replaced text..."
}