Search code examples
phpmasking

find string by mask in php


In the DB I have some strings like:

1. BBD0G.ABAEBABGBAB-AAL----BA.LLRV--B--B--.H----A---
2. BBD0G.AAAEAAAGAAA-NAL----CA.LLRV--------.H----A---
3. BBD0G.AAABCBAGAAA-A--------.LLRV------A-.H--------

All strings have same length.

How can I find all strings based on a mask like:

*******B*****************B************A***********

It should not be a rule based on value position, but a general rule based on entire mask.

Thank you!


Solution

  • Try to filter with your sql query. For example:

    SELECT * FROM table_name WHERE column_name LIKE '_______B_________________B____________A___________';
    

    The wildcard _ exactly one character. For more information see: https://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html