20,741
edits
Line 236: | Line 236: | ||
[[File:Instant-cquotes-genetic-regex-solving.png|thumb|Screenshot showing the instant cquotes script with integrated regex solving support using genetic algorithms.]] | [[File:Instant-cquotes-genetic-regex-solving.png|thumb|Screenshot showing the instant cquotes script with integrated regex solving support using genetic algorithms.]] | ||
The genetic-js framework has been integrated, it is intended to help solve xpath/regex expressions procedurally using genetic algorithms/programming. The idea is to provide a set of desired outputs, available input data, and use existing (possibly outdated) regex/xpath expressions to seed a pool with potential solutions for retrieving the desired output. For now, this is just proof-of-concept, i.e. just an experiment. | The genetic-js framework has been integrated, it is intended to help solve xpath/regex expressions procedurally using genetic algorithms/programming. | ||
The idea is to provide a set of desired outputs, available input data, and use existing (possibly outdated) regex/xpath expressions to seed a pool with potential solutions for retrieving the desired output. For now, this is just proof-of-concept, i.e. just an experiment. | |||
<syntaxhighlight lang="javascript"> | |||
var regexTests = [ | |||
{haystack: "From: John Doe <John@do...> - 2020-07-02 17:36:03", needle: "John Doe"}, | |||
{haystack: "From: Marc Twain <Marc@ta...> - 2010-01-03 07:36:03", needle: "Marc Twain"}, | |||
{haystack: "From: George W. Bush <GWB@wh...> - 2055-11-11 17:33:13", needle: "George W. Bush"} | |||
]; | |||
</syntaxhighlight> | |||
The basic idea is to run a fitness function and score regex expressions based on not throwing an exception (which makes them valid), and by checking if the desired tokens are part of the output string. | The basic idea is to run a fitness function and score regex expressions based on not throwing an exception (which makes them valid), and by checking if the desired tokens are part of the output string. |