Regular Expressions

Updated: Jan 21, 2020 by Pradeep Gowda.
Tagged: programming

VerbalExpressions were designed to make Regular Expressions human readable, without needing to learn the symbol meaning of regex. via. Example:

// Create an example of how to test for correctly formed URLs
var tester = VerEx()
    .startOfLine()
    .then('http')
    .maybe('s')
    .then('://')
    .maybe('www.')
    .anythingBut(' ')
    .endOfLine();

// Create an example URL
var testMe = 'https://www.google.com';

// Use RegExp object's native test() function
if (tester.test(testMe)) {
    alert('We have a correct URL '); // This output will fire}
} else {
    alert('The URL is incorrect');
}

console.log(tester); // Outputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/

Above example is for javascript. They have implementations for different programming langauges.

Rosie Pattern Language is intended to replace regular expressions (regex) in situations where:

  1. many regex are used in an application, project, or organization; or
  2. some regex are used by many people, or by a few people over a long period of time; or
  3. regex are used in production systems, where the cost of run-time errors is high.

essentially, rosie allows you to scale regular expressions by making them reusable, explainable and predictable.