How to overcome the error related to Regex pattern for password check?

I have Regex pattern “^(?=.[a-z])(?=.[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$”.
I am facing the error Illegal escape \d. Do we have any alternative to this in kotlin?

Have you tried \\d?

"""^(?=.[a-z])(?=.[A-Z])(?=.*\d)[a-zA-Z\d]{8,}""" + '$'

You don’t need to separate $, it’ll work just fine in this pattern.

Regex("^[\\w]{8,}$")