I have a couple comments:
1) The + character indicates "1 or more." You are then checking for 1 or more "http://" sequences at the beginning of a string. If you are checking URLs, it's common to have a single occurrence of http://, and it's also common to have no occurrences (i.e., yahoo.com is just as valid as http://yahoo.com). A better solution would be to use a ? in that case which means "0 or 1".
2) To answer your question, your problem is caused by the lack of of the ending symbol $. Regular expressions match via a needle in a haystack method if you don't include starting and ending symbols (^ and $, respectively.) Currently, without the $, it starts at the beginning, expects to finds 1 or more "http://" right there at the beginning, then next expects to find 1 or more letters between a and z. As soon as it reaches "http://y", it has a match, but it will continue to grab up to " http://yadayada" because regular expressions are greedy by default.
3) You don't have to use the $ symbol to fix your problem, but it is a good idea, because it will allow your regexp to be as strict as possible when you finish it.
Hope that helps.
|