Hello! Is it possible in laravel5.5 / eloquent / mysql to make a β€œlike” request so that by entering the text β€œA66” / β€œ-A66” would you search for the lines β€œA-66” and β€œA66”? That is, the hyphen character is as if excluded from both the condition and the text?

And if so, how?

Thank !

    1 answer 1

    The pattern can probably be picked up and prettier, but the meaning is not in it.
    We use in request instead of like - regexp

     $regexp = preg_replace('(-|\s)', '', ' A-6 6'); $regexp = preg_replace('/([a-zA-Z0-9])/', "-?\${1}", $regexp); $models = Model::where('column', 'REGEXP', $regexp); 
    • 1. Not -? , and -* . 2. Here only any injection'y push through the type .*| . - Qwertiy ♦