I'm trying to read the numbers after the last \ using regular expressions but unable to do it.
I've tried using [^\\]*$
, ([^/]+$)
but both don't work. The first one removes the numbers.
Please can you advice?
My sample data is:
C:\Users\Documents\Projects\Austraila\Customer\Organisation\176276
In JS, you may use
/\\(\d+)$/
See the regex demo
The \\(\d+)$
regex matches:
\\
- a literal \
symbol(\d+)
- Group 1: one or more digits$
- end of string.var path = "C:\\Users\\Documents\\Projects\\Austraila\\Customer\\Organisation\\176276";
var m = path.match(/\\(\d+)$/);
if (m) {
console.log(m[1]);
}
print(
string.match(
[[C:\Users\Documents\Projects\Austraila\Customer\Organisation\176276]],
[[\(%d+)$]]
)
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments