Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Dunno how much it will help, but you could also optimize by not naming the captured groups. When you name them, in addition to the named elements, $all_matches will still have the numerically indexed version of those matches, so you are basically doubling the size of $all_matches (aside from element 0 not being doubled, of course). Perhaps this is causing the server to run out of memory... For example: $string = "abc123def"; preg_match_all('~(?<letters>[a-z]+)~',$string,$matches); print_r($matches); output: Array ( [0] => Array ( [0] => abc [1] => def ) [letters] => Array ( [0] => abc [1] => def ) [1] => Array ( [0] => abc [1] => def ) ) Remove the ?<name> stuff and reference the numerical indexes instead. Or rename the numeric indexes after the match to save having to change code further down the pipe if you have to.
  2. Sounds good on paper, but in reality would not work. We all have egos. We all want to know how many of our posts were "liked" and how much they were liked. And we all want the rest of the world to know how awesome we are. And I'm not saying any of this in a bad way - getting recognition for the help you give out around here isn't a bad thing. These are all the reasons why we (or anybody in general) likes karma systems. People just want to make sure that every single little point award to every single person is absolutely 100% accurate, because heaven forbid some jackass gets awarded a point you rightfully deserved, or some jackass downvotes you "unfairly". And I'm not trying to justify those "baddie" instances... just sayin', people have a tendency to focus on the negative aspects of shit (even if there is no physical negative rep). Someone can have 10k rep and fuck all if some twat took away 1 point, image shattered, end of the fucking world sort of thing. So it's either perfect system or nothing. And since a perfect system is not possible, we get nothing.
  3. Just goes to show how much you actually read my tl;dr's or pay attention to what's going on around here... Yes, we generally try to avoid hacking the software, but we don't mind using established mods that are maintained. And there are lots of karma/rep type mods out there, and hell, I'm pretty sure SMF actually has one version in its core and we just have it disabled. I'm fairly certain most of us want one...it's just that for some unknown reason, many argue that since there is no "perfect" karma/rep system that can't be abused, it's not worth having one in place at all. There is this "fear" that it will be mercilessly abused and there will be lots of noobies running around with a shitton of karma/rep, vs. lots of seasoned pros with little to no karma, causing random Joe poster to be confused about who to accept advice from. I'm not in that boat, I do want one in place, despite imperfections. And I call b.s. on those fears. Sure, there will be no shortage of instances of people unfairly handing out good and bad rep, but overall, I think it will be okay. I think people around here have trouble with the notion of looking at things from a "trend" perspective vs. "absolute" perspective. But hey, I'm just one person, and I respect the notion of "majority rules".
  4. Lookbehind has to have a fixed length pattern to match, so you cannot use quantifiers in a lookbehind. Example: abc is a fixed length; it has exactly 3 characters. .* is not a fixed length, because it can be 0 or more characters. As DavidAM mentioned... your followup posted code and what you are saying doesn't match what it is you previously said... so as I said in the beginning, you need to try harder to be a lot more clear in what you are trying to do. Give several examples of real input and what you want the results to look like.
  5. Yes, it is a special character, regardless of where it is in the pattern..it's just that you usually only see it at the end of the pattern because usually it doesn't make sense to use it elsewhere. But it also comes up a lot if you are combining it with alternations, or with multi-line mode. Only place that it is treated literally is inside a character class. http://www.php.net/manual/en/regexp.reference.meta.php
  6. @DavidAM $ has special meaning in regex, it needs to be escaped too.
  7. $string = preg_replace('~#(.*?\..*?\$)~', '3\1', $string);
  8. You're going to have to try a lot harder to explain what you want...your post makes no sense.
  9. seems buggy in FF5.0 + jQuery v1.6.2 I have that on a test page and have it in one tab, and another tab to some other random place, and when I keep clicking back and forth between the two tabs, I seem to be only getting the alert every other focus.
  10. Can someone please explain to me what these "exercise" and "gym" things are? Are those new buzz words you kids are throwing around?
  11. all by itself it effectively does nothing, since the returned result of the preg_replace isn't being assigned to anything. At a minimum, you would have to assign it to a variable, or echo it out, or something. Point is, the original variable $variable (3rd argument in the function) isn't altered. Example: echo "before: " . $variable . "<br/>"; $variable = preg_replace('/([a-zA-Z]).*/', '$1', $variable); echo "after: " . $variable; The regex itself basically finds the first instance of a letter (case-insenstive) and removes everything after it. breakdown of the regex /([a-zA-Z]).*/ / Starting pattern delimiter ( Start of captured group 1 [a-zA-Z] Character class to match 1 of any lowercase or uppercase letter ) End of captured group 1 .* Greedy match of 0 or more of any character (other than newline character) / Ending pattern delimiter replace all that was match with... $1 whatever was captured in group 1 Examples (green is what is matched and captured by capture group 1, red is what is matched by the .*): $variable = "abc" before: abc after: a $variable = "123 Abc blah"; before: 123 Abc blah after: 123 A
  12. For the 1 millionth time, we do not develop the SMF forum software, we simply use it, just like lots of other people. We are willing to use a mod if it is well supported and kept up, but we generally will not do random hacks on the software. And it's not because we are unable to do it, it's that it's a pain in the ass to keep up with. If you want to see something like this, go post a suggestion on the SMF development community boards. Maybe the SMF team will add it, or maybe someone will make a mod that does it.
  13. $content = <<<EOF ('Row: 1, Field: 1')"stuff here('Row: 10, Field: 40') EOF; preg_match("~\('Row: 1, Field: 1'\)\"\K(??!\('Row: 10, Field: 40'\)).)*~",$content,$match); $emails = "[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]"; $emails = preg_replace('~(?:^|,)[^@]+@(??!(?:,|(yahoo|rocketmail|ymail)\.com)).)+~i','',$emails);
  14. I currently have Adobe Master Collection CS3...I've been trying to get my employer to pony up CS5 for a while now, but so far it seems the only way they will readily do it is if I basically promise to start doing things with some of the programs in the collection that I currently have little to no experience in :/
  15. Yeah, because users totally can't just disable javascript or change the enable/disable flag or similar. OP, do not do something like this. Or at least, make sure you also output a message explaining that the user cannot submit unless they reach 5. And also do NOT just blindly process the form submit by virtue of it being submitted. If you output a disabled button and then assume that the amount is at least 5 by virtue of the user being able to submit (button not disabled), the user can easily alter the client-side html/javascript to enable it and submit!
  16. Adobe has actually done a pretty amazing job at integrating their tools together so that you can pull something in from one tool to another (p.s.- as Zane alluded to, all 3 PS, AI and FW are all Adobe products and unless you buy them individually, all 3 of them are included in most of Adobe's packages).
  17. This is like asking "Which editor is the best?". Bottom line is they all do more or less the same thing, and it boils down to preference, and the only "right" answer is for you to give them a try and pick the one you like or feel most comfortable with.
  18. Your pattern has a space between the } and $ which means it looks for 1 to 40 of that stuff in char class, followed by a space. And since your regex can also contain spaces (it's in your char class and you are saying here that "Old World" should be acceptable) IMO you should update your error message to say it can also have spaces. if (!preg_match('#^[A-Za-z ]{1,40}$#i', $city)) { $errors[] = 'City must be between 1 and 40 characters and can contain only letters or spaces.'; }
  19. Aaaah...well I was fixing to make a post but then you responded. Here is what I originally wrote:
  20. Well it's "legal" as in you aren't breaking any laws, but this is considered bad practice and even a form of "black hat" SEO, depending on intentions. At best, the intention is that you're retarded and can't code properly, and Google and other search engines frown on this sort of thing, and it will hurt your SEO ranking. At worst, many of the search engines will actually black list you if they find out you are doing this on purpose to gain ranking and visibility. If you want to have multiple ways to point to the same content, include in your .htaccess a permanent redirect flag. This will let the search spiders know that you aren't trying to be shady. And this will cause only one of them to show up in search results. But if you are trying to get the same content to show up twice in search results...that's a good way to hurt your SEO ranking and get black listed.
  21. We don't have an anthem but we do have decoder rings.
  22. no clue, I've never done Active X stuff, but I'm pretty sure an Active X control is like a java applet but for MS/IE. Basically it's its own little program that is embedded onto a web page and you don't really have access to the code in it. It's not really on the page like javascript or html. Sounds like you will need to talk to whoever made or has access to the Active X object itself.
  23. That sounds more like something an ActiveX control is doing (which is not javascript).
  24. Near as I can tell, teynon "started it" here: IMO even the edit doesn't "help" or "justify" the first statement. And then PFM followed up with... xc0n clearly has problems listening or paying attention to what's being told. Maybe it's because he is an idiot, or maybe he's just another 13 year old with the attention span of a ferret on crack...who knows, but regardless, you guys bit out of frustration, and he bit back, in response. @xc0n: I'm not going to necessarily fault you for biting back, when others "started it". But people get really frustrated when someone comes asking for help and doesn't make an effort to listen to the help they asked for. If you are going to ask questions on a help forum, you need to make an effort on your end to pay attention to what is being told. If you don't understand, ask for clarification. And if you do not pay attention or try what is given, expect people to be frustrated about it and respond accordingly, and even bite you for it. And while you're certainly welcome to bite back...that obviously doesn't solve your problem. My best advice to you would be to recognize and admit (at least to yourself) that you aren't making the necessary effort, take your lashings like a man, and make it a lesson learned. Programming takes effort. For whatever you think you've just accomplished with this bit of code, it is still poorly written and vulnerable and begging for problems down the road. And when you ask for help later on it...do you really think people are going to help you, after all this? Yes, this is a "help" forum, but we arenot here to spoon feed people or do their work for them or wait on them hand and foot or walk on thin ice or any of that shit. We are here to help people with their problems when they are trying to make an effort to solve them, and to help them learn something. Have you seen any kung-fu flicks? You know like where it shows lots of monks in a monastery trying to learn kung-fu and they have the master there and when they aren't paying attention or something...WHACK. If you are serious about learning something. That is the difference between being "punished for doing something wrong" and being "disciplined so that you learn to stop doing wrong." @others: I understand being frustrated when someone isn't listening, and I understand calling them out on it, and I'll even to an extent turn a blind eye to a sharp tongue. But don't dish it out unless you yourself are prepared to be served. If they want to respond by biting back then they probably aren't all that serious about their issue or trying to learn to begin with. But don't go crying foul when someone bites you when you bit them first. Even if it is out of frustration, you're still biting.
  25. Hmm I didn't know the Joker also starred in The Event, I guess I'll have to actually go watch that movie then, eh?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.