I have a string like domainA\userNamePaul. I tried this regex (?='\\').*$ but the out put is same as input. I need to get the username without the domain. Any idea what I am doing wrong.
You need to use Positive lookbehind,
(?<=\\).*$
DEMO
Explanation:
(?<= look behind to see if there is:
\\ '\'
) end of look-behind
.* any character except \n (0 or more times)
$ before an optional \n, and the end of the
string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With