Skip to content
Advertisement

varchar number starting with +

I am trying below to find out if the column (dis_num) value is numeric or not which is working fine.

REGEXP_LIKE(dis_num, '^[[:digit:]]+$')

Now dis_num column can starts with + and then numbers like +8143434344. How to modify above regex which is consider starting with + as well ? Means if column has number starting with + then also we need to consider as numeric.

Thanks

Advertisement

Answer

If you want to check for a literal + sign you can escape it; and can make it optional with ?

Very quick demo:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement