How do I check if a string contains a number

前端 未结 4 1429
北海茫月
北海茫月 2021-01-12 10:34

I need to check if a string contains a number. Any number. Not wether or not the string IS a number, but if it contains one.

Examples:

\'test\' = no numbers.

4条回答
  •  悲哀的现实
    2021-01-12 11:34

    I sometimes use REGEXP_INSTR in NetSuite saved searches since the SQL functions are limited. It returns a zero if no numbers are found, or the starting position of the first number found in the string:

    REGEXP_INSTR(my_var, '[[:digit:]]')
    

    This example returns zero:

    REGEXP_INSTR('test', '[[:digit:]]')
    

    This example returns a number greater than zero since it found a number:

    REGEXP_INSTR('test2', '[[:digit:]]')
    

提交回复
热议问题