Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php preg match

$utterance = 'This is a brown bear with 7 kids';
$template = 'This is a {color} bear with {kids} kids';

$templateRegex = '/' . preg_replace('/{(.*?)}/', '(?<1>.*?)', $template) . '/';

$matches = [];
preg_match($templateRegex, $utterance, $matches);

var_dump($matches);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #preg #match
ADD COMMENT
Topic
Name
6+6 =