w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Match a sequence of numbers preceded by certain text

You can place a capturing group around the part you want and refer to that group number for the match result.

re.search(r'sampleurl/(d+)', url).group(1)

Another way would be implementing a lookaround assertion.

re.search(r'(?<=sampleurl/)d+', url).group(0)




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.