Regular expression to read only digits after last slash

edcoder

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
Wiktor Stribiżew

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]);
}

Lua solution:

print(
    string.match(
        [[C:\Users\Documents\Projects\Austraila\Customer\Organisation\176276]], 
        [[\(%d+)$]]
    )
)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

only keep digits after ":" in regular expression in python

Javascript regular expression: remove first and last slash

Regular Expression only digits and blank spaces

Regex to extract only digits after last whitespace

REGEX expression: get the two letters after the slash or after the last dot

Slash in regular expression in Golang

Regular expression in python to replace last two digits of a column value where if last two digits are 30 then replace it with 50

Why is this regular expression only capturing the last digit?

Regular expression to find last colon after timestamp

Regular Expression For Duplicate Digits

Regular Expression With Unique Digits

Regular expression to capture the digits

Regular expression for digits

Regular expression to match digits

Java Regular Expression - allow only certain characters and digits

regular expression detect any number of digits separated by only an hyphen

Regular Expression to mask any string matching 10 digits only in golang

How to make regular expression with only 3 characters and 3 digits?

Need Help In Regular Expression - Match 6 digits after specific word

Regular Expression to match exactly the digits after the first dot in a string

Regular expression to match all digits of unknown length except the last 4 digits

How would I write a Regular Expression to capture the value between Last Slash and Query String?

Regular expression for 10 digits or 11 digits

Regular expression 2 digits 10 letters/digits

regular expression for recurring digits in python

Java regular expression for digits and dashes

Regular Expression inner Digits check

Regular Expression for Ignoring specific digits

Regular expression for digits, decimals, and fractions