Search packages, repositories and app categories

Package detailsv1.0.0

verbal_expressions

A package that helps to construct difficult regular expressions.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
71
Likes
20
Pub points
160

Install package

flutter pub add verbal_expressions

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

VerbalExpressions is a Dart package designed to simplify the creation of complex regular expressions through a fluent, readable API. It allows developers to build regex patterns step-by-step using intuitive method chains, reducing the likelihood of errors and improving code maintainability. Ideal for parsing structured text or validating input formats, it abstracts away the complexity of raw regex syntax while preserving full functionality. The package supports all major platforms, making it versatile for cross-platform applications.

Use cases

  • Text pattern validation
  • Input sanitization
  • Data extraction from strings
  • Parsing structured logs
  • Building reusable regex builders

Key features

  • Fluent, chainable API
  • Readable and maintainable regex construction
  • Supports all standard regex operations
  • Cross-platform compatibility
  • Easy integration with Flutter apps

Suitable for

  • Developers building form validators
  • Teams prioritizing code readability
  • Projects requiring dynamic regex generation
  • Applications processing user input or log data

Considerations

  • May add slight overhead compared to raw regex
  • Not ideal for extremely simple patterns
  • Requires understanding of basic regex concepts

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Pub Package Build Status Coverage Status Github Issues

verbal_expressions

A library for Dart developers that helps to construct difficult regular expressions.

Dart package info is here: https://pub.dartlang.org/packages/verbal_expressions

Quick start

  var regex = VerbalExpression()
   ..startOfLine()
   ..then("http").maybe("s")
   ..then("://")
   ..maybe("www.").anythingBut(" ")
   ..endOfLine();

  // Create an example URL
  String url = "https://www.google.com";

  // Use VerbalExpression's hasMatch() method to test if the entire string matches the regex
  regex.hasMatch(url); //True

  regex.toString();   // Outputs the regex used: ^http(s)?\\:\\/\\/(www\\.)?([^\\ ]*)\$

  var regex = VerbalExpression()..startOfLine()..then("abc")..or("def");

  var testString = "defzzz";
  //Use VerbalExpression's hasMatch() method to test if parts if the string match the regex
  regex.hasMatch(testString);   // true

Feel free to use any predefined char groups:

  var regex = VerbalExpression()
	  ..wordChar()..nonWordChar()
	  ..space()..nonSpace()
	  ..digit()..nonDigit();

Define captures:

  var expression = VerbalExpression()
   ..find("a")
   ..beginCapture()..find("b")..anything()..endCapture()
   ..then("cd");
   
  RegExp regex = expression.toRegExp();

  var match = regex.firstMatch(text);
  print(match.group(0)); // returns "abcd"
  print(match.group(1)); // returns "b"

Examples

More examples are in example file

Features and bugs

Please find feature requests and bugs at the issue tracker.

Other implementations

You can view all implementations on VerbalExpressions.github.io

[ Javascript - PHP - Python - C# - Objective-C - Ruby - Groovy - Haskell - C++ - ... (moarr) ]

Categories

Source repository

Projects using this package

No data available yet.