Sorry, but I am a regular kettle. I sit studying the manual and seravno does not reach

^[iI]{1}[dD]{1}([1-9]*)$ 

It is necessary not to miss ID + Number
For example
id123
Id123
ID123
iD132
id
123
Help please

  • Try to write more detailed questions. To get an answer, explain exactly what you see the problem, how to reproduce it, what you want to get as a result, etc. Give a sample code. - Grundy
  • I do preg_match () So I need him to catch the above inscriptions - KupueIIIKo

2 answers 2

Since there are two groups that can be present independently of each other, is it worth separating them and using a quantifier ? which indicates that the group can be repeated once or absent

 (id)?(\d+)? 

To check was not case sensitive, you must use the flag i (ignorecase)

 /(id)?(\d+)?/i 

Perhaps you can do with one group.

 /(id)?\d*/i 

    This is for search

     id123 Id123 ID123 iD132 id 

    separated by spaces: \s?([Ii][Dd])(\d+)?\s