PHP code example of bassim / super-expressive-php

1. Go to this page and download the library: Download bassim/super-expressive-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bassim / super-expressive-php example snippets


$myRegex = SuperExpressive::create()
  ->startOfInput()
  ->optional()->string('0x')
  ->capture()
    ->exactly(4)->anyOf()
      ->range('A', 'F')
      ->range('a', 'f')
      ->range('0', '9')
    ->end()
  ->end()
  ->endOfInput()
  ->toRegexString();

// Produces the following regular expression:
/^(?:0x)?([A-Fa-f0-9]{4})$/