sqloracle-databaseregexp-like

sql - what does '^\d+\D+$' mean in regexp


I came through an expression -

select * from table where regexp_like(field, '^\d+\D+$');

I'm sure of what the expression does, but please can someone explain what '^\d+\D+$' refers to exactly?

Thanks.


Solution

  • ^ beginning of string

    \d single digit

    + one or more occurrences of preceding

    \D nondigit character

    + one or more occurrences

    $ end of string

    So, it means one or more digits followed by one or more nondigits, and that should be the whole string, not a substring.