$re = '~(?(DEFINE)
(?<chars>[-\w]) # equals to A-Z, a-z, 0-9, _
(?<af>=>) # "arrow function"
(?<item>
(?!(?&af)) # no af at the beginning
(?:(?&af)?(?&chars)++)+
(?!(?&af)) # no af at the end
)
)
^(?&item)$~mx';
$str = 'Field_name_true2
abc=>d
=>abc
abc=>abc
somewhere_over_the_ocean=>
somewhere_over_the_ocean=>dda
somewhere-over-the-ocean
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php