[Solved] Custom Regular Expressions [closed]


This is very bad practice, but because you asked for it:

$str="BCT34385Z0000N07518Z";
preg_match('/^(.{6})(.*?)$/', $str, $result);

echo $result[1]; // 'BCT343'
echo $result[2]; // '85Z0000N07518Z'

or if you want an if statement:

$str = ...;

if (preg_match('/^BCT343/', $str)) {
    // yes!
}

2

solved Custom Regular Expressions [closed]