-1

Can anyone give me the pattern of the regex to get all the local images ONLY. :( I'm using the code below but it includes the image links.

  Regex rgx = new Regex("[^\\/:*?\"<>|]+\\.(?i)(jpg|png|gif|bmp)", RegexOptions.IgnoreCase);

input:

 http://dl9.glitter-graphics.net/pub/846/846279rr8zhg26y6.gif
 images/strawberries.jpg

output:

 846279rr8zhg26y6.gif
 strawberries.jpg 

I don't want the 846279rr8zhg26y6.gif

Anthon
  • 69,918
  • 32
  • 186
  • 246
Aby Bendo
  • 1
  • 2
  • what is the output that you are looking for – aaronman May 03 '13 at 04:02
  • If images is guaranteed to be in the location you could just do something like `images\\/([^\\s.]+)\\.(jpg|png|gif|bmp) – Patashu May 03 '13 at 04:16
  • If the task is specific enough then regex searching data that happens to be html is fine. In this case it seems the actual data is URLs however. – ChrisF May 03 '13 at 05:02

1 Answers1

0

If your input strings are bounded somehow (e.g. inside ""s or at the start of the input string) then things are easier, and if the input has a semantic context of being a (relative or absolute) URL, and you only want relative URLs, then easier still.

I would however note that the extension part should probably be jpe?g rather than just jpg and I do wish people would never ever use a bmp on a webpage!

ChrisF
  • 180
  • 8
  • This seems more suited to be a comment than an answer – Patashu May 03 '13 at 05:01
  • I have this all HTML files and all I want is to filter the source of the images that is in local disk. Not the source that I can access through the internet(URL Links) because I will add cid (programmatically ) to those in the local images. – Aby Bendo May 03 '13 at 05:21