Home>

Sample table. Regular expressions are stored in the Prefix column.

ID Prefix
1 66 | 2
2 661 | 244
3 22 | 11
... ...

At the entrance comes numbers. It is necessary to get the ID where the first digits of the incoming number are suitable for a regular expression, which should be the most accurate match.

Example
661234567 ->
 ID: 2.
221234567 ->
 ID: 3.

Is it possible to get one select?

Can you suggest a solution? Thanks

Can. Only you have a weekly no "regular expression", it is a CSV curve.

Akina2021-08-20 20:12:09

Thanks for the answer. Maybe you are right. The essence is to determine which template is the number. An example of a template (I write text to not caused errors of regular expressions): -Prefix can be 66 or 2. -Prefix can be 33, 32, 31 (in Asterisk, this template will look like "3 [1-3]") `

tereshok2021-08-20 20:12:09

Boarding a field with a "template" on two separate. Tie with the resulting set by compliance. Choose that correspondence in which the prefix length is maximum.

Akina2021-08-20 20:12:09

What do you mean to stealing? Do you want me to create any other fields in the database and add the prefixes you need there?

tereshok2021-08-20 20:12:09

And then, "binding to comprehension" did not understand at all ...

tereshok2021-08-20 20:12:09