0

I am working on a project where i need to grab some text and the only option available to do this is through regex. If anyone here can help, then please let me know what would be the correct command/syntax to capture the file number from the below URL.

https://k.nooncdn.com/t_desktop-pdp-v1/v1589276842/N14058677A_1.jpg

In this case the text i wish to capture us "N14058677A".

Thanks! TM

  • Can you please provide more info, what have you tried and what's not working for you? – resu Jul 23 '20 at 17:34
  • More examples would be helpful, but for the one example you've shown you can use `(?<=\/)\w+(?=_\w*\.jpg)`. [Demo](https://regex101.com/r/zasM8K/1) – jdaz Jul 24 '20 at 04:42

1 Answers1

0

You can use: .{10}(?=_1.jpg)

Notice that it will work only if the name of the file ends with "_1.jpg" and will take the 10 characters that came before. In order, to improve the formula, more examples are needed.

Or

N[\d]{8}A

If it always starts with an "N", got 8 numbers and ends with an "A"

Doron
  • 11
  • 7