Your host-or-ip part of the regex "(a-zA-Z0-9-+)\.(a-zA-Z{2,3})" does allow at maximum a single dot inside. Therefore "xyz.com" can never match. I do not know what your specific requirements, but you may go with something like "(^/?
#:+)" for the host part.
No, actually I need to extract urls, the one provided in the question is part of a string, so I need to extract those urls, the regex above does it but its not consistent. – Sandhurst Aug 7 at 7:28.
A-z0-9\. \-_\#%&=/? ;,!
:~@\$\++)#iu', $text, $m); It's on the assumption that a URL starts with https:// or and then can have a sequence limited to a special set of characters. Then I can use www.php.Net/manual/en/function. Parse-url.
Php on $m to get all the URL's details Edit: Also, if you are parsing text, you might want to check for periods (.) and other punctuation at the end of the URL. I've noticed that humans may put a . At the end of the URL if the URL is at the end of the sentence for example like example.com.
So I do something like this: if (($url$pos==='!') || ($url$pos==='. ')) { // probably do not want these chars at the end of a url! $url = substr($url, 0, $pos); }.
1. You can also use a lookbehind to force the regex itself to back off if the last matched character is one of the forbidden ones: '#https? ://a-z0-9.
_\#%&=/? ;,! :~@$+-+(?!)#iu' – Alan Moore Aug 7 at 22:16.
How about you match everything beginning with or https:// ((?:http|https)(?::\\/{2}\\w+)(?:\\/|\\.?)(?:^\\s"*)).
Works just fine.(2) / only needs to be escaped if you use / as the regex delimiter; there are many other options.(3) Double escaping isn't necessary if you use ' instead of " as the string-literal delimiter.(4) Inside a character class, . Doesn't need to be escaped and | is not an "OR" operator, it just matches a | (the "OR" is implied).(5) /.? is pointless anyway, since ^\s"* matches both those characters.(6) There's no need to wrap the whole regex in ().(...) I could go on... ;) – Alan Moore Aug 7 at 21:58 Yeah but it works ;) all good. – Chamilyan Aug 7 at 23:11 Well, it correctly matches the one example the OP provided.
You're okay if the URLs are always enclosed in double-quotes as they are in the text of the question, but I don't think that's what the OP meant to imply.(But I'm wrong anyway: your regex also matches the http://www.gob.In "http://www.gob. ", which is obviously incorrect. ) – Alan Moore Aug 70 at 0:35.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.