cityuk wrote:
Dear All,
Hello,
This is more of a generic question on regular expressions as my program is working fine but I was just curious. Say you have the following URLs: http://www.test.com/image.gif http://www.test.com/?src=image.gif?width=12 I want to get the type of the image, i.e. the string gif. For the first URL the regular expression .*\.([a-z]{3}) will do the trick while for the second one I am using .*=\([a-z]{3})?.*. Ignoring the fact that the REs can be written better my question is: If I put them together, that is write them as .*\.([a-z]{3})|.*=\([a-z]{3})?.* perl thinks that the or only applies to the characters immediately surrounding it (in this case ) and .).
No. The alternation applies to the complete pattern '.*\.([a-z]{3})' OR '.*=\([a-z]{3})?.*'.
John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/