Splitting out filename parts using Regex

We have an image server that keeps cached versions of different sizes of images. The image filenames are in the format _wh.jpg

The 'w' and h' numbers are optional. Examples of possible requests are:

1234.jpg, 1234_w200.jpg, 1234_w200h160.jpg, 1234_h160.jpg

I need to be able to split these parameters out using PHP and a Regular Expression but can't work out how to do it (my regex experience is very limited). A key thing is that if only a width is passed as opposed to both a width and a height, I need to know that it's a width and not a height (if that makes sense).

Any ideas?

Thanks in advance!


Category: php Time: 2016-07-28 Views: 0
Tags: regex php

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.123 (s). 12 q(s)