Good Day Folks!

  1. Is the following regex ok to extract top level domains and 2nd level domains ?
    [^.]*.[^.]{2,3}(?:.[^.]{2,3})?$

  2. How to write php code to use that regex ?
    Any sample code welcome.
Member Avatar for diafol

OK you now get put on everybody's ignore list. Bye.

Can't seem to upvote w/ comment on Diafol's post. Hmm.

This will be my last time commenting on any of your posts UI. In case you didn't realize, this is a major breach of forum etiquette. If you didn't know that, now would be the time to simply acknowledge that. No excuses, no explanations, no humor. Just "I screwed up. Sorry.". If you are.

Not sure why you are unable to +rep diafol, I just looked and it would let me (although I didn't follow through, ooh err missus)

commented: Frankly Frankie it's not good enough :) +15

Best to ask your questions on as many forums as possible because you get a variety of answers and you don't know which is right since you can't see who (amateur or pro) are giving the answers. Best to try-out all answers and see which one suits you best. Then, you hold onto those programmers.
AssertNull, I held onto you (so to speak) in this forum but you made it plain you're not a php pro and so what's the harm in asking in many forums to see who can be your next pro buddies ? I'll still accept your replies here because even if you consider yourself not to be a pro, your answers have been satisfying to me.
I tell you what guys, note all my threads in this forum and then google it. I've got nothing to hide. You'll notice that, whatever I asked (same questions) here, I also did on others (about 10) within the last 3-4 mnths but not all were responsive or satisfactory. Later, stuck with 6. Now with 4. Only one forum banned me without a warning or explanation. Found myself unable to login and get alert I have been banned permanently. Other forums and other forum members too are aware that I'm asking same questions on more than one forum. Majority of them don't care. One member even said that, there is nothing wrong with what I'm doing, even though 2 members there did!
I believe it's my freedom of speech...... (whatever!) to ask and learn from as many places as possible gaining a range of answers as work experience. You all may have studied the same course but you all don't have the same work experience and so best to learn from each and every one of you. Likewise, best to learn from other sources too. Nothing wrong with that. God given right to learn however you freely wish!
Like I said, only 2 bothersome people there did have a problem with it thinking their answers better than everybody else's on the planet and just expected me to take their word for it like Bible doctrine and expected me to forget the rest (even you guys) but they usually are rude and one of them got an infraction lately. You'll be amazed how programmers get jealous on each other and expect you to take their words for it over all other forums but I still stuck with you guys ignoring their weights and their breathings down my neck!
Whatever, I learn from you guys, I go and share it on other forums. Whatever I learn on other forums, I update here on my threads what I learnt from these other sources. Info exchange. I do this so all newbies (and oldbies) alike can learn from the answers. Not all "pros" are equal in knowledge. Sometimes, even the adv guys learn a little or two from intermediate guys and I hope they learn something from my threads when I share what I learnt on other forums. It's just one way to give a thank you for answering my threads. Come-on! You guys contribute to me! Why can't I return the favour ? You never know, you might learn a little something from my threads when I mention what I learnt from other sources. You just never know.
Different walks of people have different levels of knowledge. I seek all that. To learn & to share. Not illegal, to do so.
If you guys like, you may do a peeping tom to see what I learnt from other forums. What answers you gave me here and what answers others gave to me elsewhere. Then, you decide whether I benefitted from multi forums or not. You might even learn a little or 2 things new yourselves trailing my online footsteps. Lol!
Oh by the way, I don't open a thread here and get answers from you and then suspect your answers are wrong and then go and ask the same questions elsewhere for confirmation. No. I just open many tabs in my browser and post the same question on many tabs that are opened to many forums. Open the threads with the same question on many forums simultaneously. Then next day, I check which forum bothered to reply what and which ones not. That way, I only stick with the responsive forums and weed-out the rest. I can't afford to open a thread in one forum then 24 later see that I got no replies or the answers weren't satisfactory and then try another for that night and so on like that everynight (one forum per night) as that way I'd be losing days in the week just to get one question answered. My learning would go at a snail pace or worst come to a standstill!
If it looks bad that, many forums having threads opened under the same title then let the moderators say so and I can always re-phrase or change the titles sightly on each forum and maybe also the content but the nature of the questions would be the same. Coming from the same angle or a variety.
I hardly ask questions at stackoverflow. Just did last night to see what level of answers I get. I stopped visiting them about 3 months back or so. It seems rprofit lost his temper when he saw the same questions asked here! Lol!

PS - AssetNull, I'm not sorry to ask same questions on more than one place. More like proud I've done it and I'll keep on doing it. Like I said. it's my God given right to learn from wherevere, whenever, however and as many as ever I can from them.
Hey, let's make a song out of this: "Wherever, whenever ..." wasn't there a Shakira song like that somewhere ?

Member Avatar for diafol

Best to ask your questions on as many forums as possible because you get a variety of answers and you don't know which is right since you can't see who (amateur or pro) are giving the answers. Best to try-out all answers and see which one suits you best. Then, you hold onto those programmers.

You ignorant, entitled clod. You don't own us or have us at your beck and call. Who the hell do you think you are? We volunteer to help those that WE deem fit, it's not the other way around. You waste EVERYBODY's time, effort, patience and goodwill by posting to multiple sites at the same time. We do all the hard work, you sit back and tell us after a couple of days not to bother since you got an answer you like the look of on a different site. Thanks, but no thanks, it's a "f*** you very much" attitude. You could have apologised and made amends, but no, you carried on in your entitled manner, trying to justify this selfish opinion. At least we won't have to listen to your "men are strong, women are pretty" bullshit anymore. ...mike drop...

Thank you for your willingness to help.
I'm a complete beginner in regex and so any suitable tutorial suggestions for complete beginners are welcome too!

Anyway, as you know, different webpages would have different internal & external links all over their pages. No matter, what the link looks like, the domain should be extracted. Imagine, I'm running a web crawler, it would encounter unlimited links where some would have just domain and some subdomain and so on.
Eg.

http://domain.com
http://subdomain.domain.com

www.domain.com
http://www.domain.com

http://www.domain.com
http://subdomian.domain.com

domain.com/dir
subdomian.domain.com/dir

domain.com/dir/sub-dir
subdomian.domain.com/dir/sub-dir

Note: No matter how many subdomains or levels of domains (3rd level, 4th level, etc.) or dirs or sub-dirs (regardless of levels) the links contain, the 2nd level domain should be extracted along with it's tld.
From our examples above, the script should extract "domain.com" from all the above mentioned links.
I need an example of the php code too alongside the regex.

What the hell, I'll break my rule and answer.

When you post the same question at the same time to multiple forums and DON'T tell all the forums about the others, there's a very good possibility that two or more "pros" as you term it on different forums will each spend a half hour patiently crafting the same answer, not knowing that the question was already answered earlier by another "pro". Hence time completely wasted. Preventable if the OP takes ten seconds to inform each forum of the others' existence.

If you don't understand why the above is rude behavior, I can't explain it any better than that. Perhaps if you'd ever spent any of your own time at all answering OTHER peoples' questions, you'd understand the concept.

As far as me not being a PHP "pro", that's a copout. I'm more than good enough to answer YOUR questions. When I don't know the answer, I don't post. I was "pro" enough to catch the main problem in your last thread. Instead of trying to understand the advice or asking for clarification, you started babbling about female programmers.

UI
You're not listening.
Nobody here is going to waste their time posting to help you when you probably already have an answer from another site.
You don't even have the basic decency to mark thread "solved" so people don't put effort in when you already have a solution.

You blew it. You're on your own now.

UI
I see you're not listening about cross posting. Initially I was going to try to find a recent post about a visual regex that helps us look at regex another way but then when I searched I found you posting in 4 or more forums. It took me a while to find it.
https://www.daniweb.com/programming/software-development/threads/508393/visual-regular-expressions#post2220172
and http://regviz.org/

It's time for you to pitch in and help others to learn how knowledge sharing works.

I am not going to be rude or fight with you guys. Not gonna lash out like Diafol (the kid is young). Not my nature. Nor my style. Too old for that sort of thing. Plus, once a friend, always a friend. Unless, ofcourse you physically or mentally start abusing.
When someone volunteers to reply to my threads, they auto become my friends, buddies, pals, mates. End of story. There are no "please", "sorry" and "thank you" with friends but I'll keep-up the latter. There is no vitamin for the soul unless you humbly give thanks to others here and there now and then.
I'm glad none of you have replied with abuse (excluding the ONE). This has revealed to me your mentality and ages. When I asked 2 others in another forum where they come from and their age range (so I can address them accordingly) they were reluctant to say. I find it difficult to deal with people online if I don;t know a little about their backgrounds. Different people have different mentality and I like to read into their "psych" and approach them in a manner that would make them open-up. But because, I found programmers are fussy to keep their privacy uptight it's best to find-out in other ways and I have just done that.
I believe AssertNull to be the oldest here (over 50). Senior. Diafol, probably a teen or a late 20's guy. Short circuit. Best to avoid him (No offense, but shove him and his language under the carpet and ignore him). Give him what he begs for (an aoplogy) if you want to still make use of him.
AssertNull, I reckon his the guy who will get a little dissapointed or cross with you but not in his nature to hold grudges. He'll come around. We'll see. Time will tell. Actually, I should've kept quiet and waited to see if he comes around. This post will tick him off. But, like I say, some people are forgiving in nature and sometimes it comes with the age. yeah, I know I'm blabbering but I'm not grieving I've lost mates because like I say, some of you will come around. Eventually, at the end.
Others middle-aged here and not so patient like the old fella!
Let's see how each of them get ticked-up after this. Lol!

Guys, it's like this ...
I ask same question on 10 threads. And mention on each thread that I have 9 more open. Do you honestly think a single forum would reply ? Each of them would think "Ah! He'll get his answers on the other 9. Why should we bother here ?" And so, what would be the result ? 10 forums. No replies.
Ok. I admit, AssertNull is right. Some programmers would answer the same and their time gets wasted. But, like I say, no-one really answers 100% same. And when I get same answers then I know I got the best answer or the right answer over those answers that hardly got others saying the same thing.
Just look what happend now when you lot found-out I've got threads in other forums open with same questions. None of you want to reply anymore. Same would've happend to all forums and I never would have got any replies from any forum.
Also, linking to other forums where the same questions have been asked is gonna create a ring which is bad for seo. Bad for all forums involved.
Also, I feared that, if I ask one question here and a different question elsewhere and then invite you guys to go and answer my other questions on those other forums then the mods in each forum would see I'm driving their members away to other forums and then ban me. You see, I did think all these things thoroughly before taking my steps. Only did what I thought was best for me and everyone (or atleast, less damaging for everyone). You do understand now why I did, like I did ? Right ?
Actually, one day, I was gonna run my own forum that I build and invite all responding programmers from all forums to reply there. That way, you never complain like you are doing now. But, like they say, territory and loyalty plays a role and you guys would have got the wrong end of the stick and would have jump to conclusions that all my questions on this forum and others were purely for the sake of introducing my forum to you all to attract members by backstabbing the current forums. You see, we really get no-where. And so, I had no choice and did what seemed best at the time.

Nice weekend & Take care!

PS - AssertNull, It was you who said you weren't a pro in php on one of my threads but I said here that, to me you were enough. Now, you're jumping to conclusions that I get answers from you and then tell it to your face you are not a pro and to shut-up. That's not the case, mate. Again, getting hold of the wrong end of the stick! Dear me!

Thanks rprofit for the links.
AssertNull, you see what I mean by mature guys, like you, would come around and they're all forgiving ? Lol!
Sssshhh! I'll groom Diafol now and then. He'll come around too! Lol!

Diafol cries:

"We do all the hard work, you sit back and tell us after a couple of days not to bother since you got an answer you like the look of on a different site. Thanks, but no thanks, it's a "f*** you very much" attitude."

Oh dear oh dear! We do have a communication problem somewhere along the chain, now don't we ? Just where did I say to anyone here that, when I get answers from elsewhere then I don't care what you guys reply in this forum because your answers are crap and I'll stick to the answers I got elsewhere ? Oh dear! Oh dear!
I said, even if I get answered in other forums, I still wait for your answers here. because, like I said, different programmers have different work experience and even a pro can learn a little from an intermediate or a beginner and therefore, i never discriminate and wait for answers here and give due credit. Every little answer I get, regardless from where, is valuable to me in it's own right. Now, that is not a f**k you!" attitude, is it ?
Oh dear oh dear!
It's like they say: You tell them one thing but they understand another.
It's like Jesus said: Seeing they see not! Hearing they hear not!

commented: UI, please stop it -3
commented: You are sounding more and more like a 14 year old troll every day... -3

Jamie Cherill,

I wasn't aware of the "Solved" feature. Thanks for bringing it up.
I usually do not prowl forums, you see. That's why not used to these features. Not aware of them that much.

commented: My name is still not Jamie -3
commented: Jimmy? Jammy? Pah. James too much of a mouthful... I give up. -3

Just find the ban hammer.

Member Avatar for diafol

You just don't get it UI - still you don't get it. This is an open forum, everybody s allowed to contribute. You don't own a thread, even if you started it. You don't get to bar a member. Only admins get to do that - the very people you've been alienating with your tl;dr rants. You however, have been placed on countless ignore lists, by the very people who are in a position to help you - so the "barring", has already been done (in reverse), so rest easy, many of us shall not attempt to help you in future posts. Moderators and admins are very forgiving and try to channel exuberance into a productive contribution. You have taken hints of criticism as a platform to rant incomprehensibly about things far and wide, which are of no interest whatsoever to members.

You admit to not knowing about the solved button, even though I told you how to solve threads on two separate occasions. You just don't listen. You do not have to listen to every single suggestion, but when everybody tells you that you are wrong, you carry on regardless, admitting that you are ignorant of forum etiquette and that you are a newbie. You are wasting people's time, but you could not care less, trying to justify it in some weird "pay back later" way.

Daniweb welcomes all new members, but I think it's safe to say, you will not be missed if you decide to leave. You do not seem to possess the qualities required to conduct an adult discussion. If members here (including myself), have reacted strongly to your posts, perhaps you should pause to wonder why. Is it that we are all egotistical idiots? Or could there be another reason? Hmm...

Diafol,

Mmm. I'm thinking now. And this is what I've "got it".
Your only reason is that you think you were made to answer questions that have already been answered on other forums and you deem it a waste of time. Hence, the lashing out. That's your problem.
But my complain is, look how others gave their explanations why they don't like what I'm doing. Mature complaints.
But youngsters like you lash out with bad language, right at the beginning. That's my problem with people like you. And yes, the more you misbehave lashing out the more I deliberately will ignore you.
If what I've done was wrong then it's the forum TOS's fault for not making it clear that it's against their TOS to open threads that are open on other forums.
Forum ettiquette ? Why wasn't it added on the forum TOS ?
Anyway, I've got better things to do than reply to nagging and bickering. Like continue programming. End of discussion. Period. I wish to no longer discuss this subject any further.

Good day!

commented: Read my complaint - you will find an explanation +0

If what I've done was wrong then it's the forum TOS's fault for not making it clear that it's against their TOS ...

Just for the record: there is nothing in DaniWebs TOS or Member Rules that prohibits posting the same questions on multiple sites. In the past Dani has said she thinks it's OK, so don't expect the rules to change.
But...
Individual members are free to hold their own opinions on cross-posting, and to express them in words and/or downvotes if they feel someone is disrespecting their role here.

Just for the record: there is nothing in DaniWebs TOS or Member Rules that prohibits posting the same questions on multiple sites.

Quoted from the rules...

Do not post the same question multiple times

Now I imagine this pertains to multiple postings on Danweb, so it doesn't violate the letter of the rule, but if you think about the reason for this rule (wasting peoples' time), UI sure violates the SPIRIT of the rule.

IMO on forums in particular it's the SPIRIT of the rules that really matter. From that point of view, I'd say that UI has broken these too...

  1. Do not post anything with malicious intent against another member, including, but not limited to, racist, sexist or religiously prejudiced remarks
  2. Do not post insults or personal attacks aimed at another member

I don't think anyone still needs to be convinced that UI is trolling. This isn't someone making a mistake or being overly-familiar on accident, but generally meaning well. Potentially someone could call you Jamie once, mean well, and just get it wrong. Continuing to do it AFTER you've made it clear you don't like it (and if you browse other forums, you'll see this is a pattern) is trolling. Speculating on peoples' nationalities, genders, and ages is the same thing. He knows I'm under 50 and he knows Diafol isn't a teenager.

The guy's a troll. You yourself have named him as such and posted an alert to that effect so no one would waste their time answering a technical question. If that's necessary, why's he still around? Are the mods going to watch this forum like hawks and put that warning up every time he posts a new thread?

you will not be missed if you decide to leave.

Why is staying even an option? You can't rehabilitate a troll. You can't tolerate a troll. All they do is bring down a forum's quality. I've mod'd forums before and there's disagreements among mods about how tolerant they should be to rule-breakers and how much benefit of the doubt to give folks, but this one's clear-cut, isn't it? Daniweb is hanging on threads.

At any rate, this is the straw that broke the camel's back for me. I've had some good times here and I wish Dani and Daniweb the best, but I just can't remain a member of a forum where guys like this aren't banned. It takes the fun out of it.

Hey AssertNull my friend - take a deep breath. You are far too valuable here to lose.

I agree with you. but Dani's protocols for Moderators are very clear, and I can't penalise anyone for anything other than a clear, unambiguous, objective rule violation. She has also given us recent guidance re encouraging people to contribute so we are on a "light touch" strategy with new posters.

In retrospect, had I known how this was going to play out I would have invoked relevance and keep it pleasant right at the start. But since some long-established and valued members have descended to the same level it's hard to fix it now.

I'm asking everyone to stop responding in any way to any further nonsense from UI. (S)he will hopefully have the maturity to respond appropriately, or maybe lack that maturity and just get bored, or maybe, just maybe, get back to sensible programming discussions and become a valued member.

Time for eveyone to step back and get back to doing our usual good stuff. Please.

commented: Move along here, nothing to see... heh heh +15

Sadly the nonsense has continued, so I just banned UI for repeated unrepentant irrelevant trolling of valued DaiWeb members.
Maybe that will cost me my Moderator badge, but someone had to do something.
JC

Update: happygeek disagrees. He's an admin and has overridden my ban (as is his right). Its out of my hands now <sigh of relief>.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.