DenCowboy
DenCowboy

Reputation: 15076

How to match following regex?

I have the following oneliner:

Download of file /xxx/xxx-xxx/Xxx/Xx_XX/xxx/xxx xxx/Xxxx/xxxx/xxxx.png to /home/ec2-user/xxx/xx/xx/Xxxy/xx_XX_XX/xxx/xxx xxx/XXX/xxxx/Xxx.png failed

How can I match the first /xxx/xxx-xxx/Xxx/Xx_XX/xxx/xxx xxx/Xxxx/xxxx/xxxx.png? It will always start with "/" and always end with .png. The rest in between can me chars, capitals, numbers, spaces, _ and - (everything). How can I match this regex?

Upvotes: 1

Views: 72

Answers (2)

Toto
Toto

Reputation: 91385

N oneed for lookarounds, use:

/.*?\.png

It finds the match in 55 steps, the other answer matches in 217 steps.

Demo & explanation

Upvotes: 0

(?<=file ).*(?= to)

yields the wished result. Online

Upvotes: 3

Related Questions