I am looking for a regular expression that works for numbers and letters / letters, but does not work for numbers.

How to do it? Example:

asdfdasf = true dasfasdf1234 = true 1234dafsasd=true 231234 = false [a-zA-Z\d]+ проблема этого выражения в том что 23124 = true 

    3 answers 3

    I want regulars, you can regulars. But only two. The first [a-zA-Z\d]+ , the second [a-zA-Z]+ . and then just make a condition (результат_первой && !результат второй) .

    UPD: If you think a little, it becomes clear that there must be at least one letter. Therefore, this is born

     [az\d]+[az][az\d]+ 

    If you need large letters, it is easily corrected.

     [A-Za-z\d]*[A-Za-z][A-Za-z\d]* 
    • This is a good option, but I can't do it the way I write them inside the flex file. Trying to get a small lexical analyzer for a file with settings. - igumnov
    • so you would hang a regular okrom tag;) - thunder
    • flex.sourceforge.net/manual/Patterns.html#Patterns is an orthodox manual, but I can’t get it right now. - igumnov
    • I’ll check UPD - igumnov
    • @Kovadim Yes, thanks, it worked. Hundreds of oil from me. - igumnov
     /^(?:\w+|\w+\d+\w*|\w*\d+\w+)$/ 

    It works only in the case of letters, either at the beginning at least one letter, then at least one number and possibly further letters, or perhaps letters, at least one number, after which at least one letter.

    This is PCRE.

    • Thanks, but I have already compiled the necessary parser. Eats megabyte ini file for a half second. Maybe someone else will need your regexp. - igumnov

    I do not know, but it seems to me that for such purposes a regular schedule is not needed. It is enough just to check the value with the function is_numeric () or is_int ()

    • Thanks, but I need exactly the regular expression, since I'm not working with PHP - igumnov