Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. load balancing isn't usually done w/ php...
  2. .josh

    url regex

    Here you go... preg_match("~.*~",$url,$match);
  3. It's when you have to hunt for your thanksgiving dinner but the damn bird keeps running around you and won't sit still.
  4. javascript cannot do this.
  5. yeah sorry OP but a few questions in I decided to call it quits..I wasn't really diggin' waiting 10-20s per page load.
  6. maybe it's just me, but that site runs super slow...
  7. .josh

    Hash Key?

    The most immediate reason why your regex is failing is because ^ and $ tell the regex engine to match the beginning and end of string. So in other words, you are telling the regex engine that the whole string must be that hash, nothing else. If you remove those anchors, you will get it to match. However... it will match any 32 alphanumeric substring within the content you are scraping. Ideally you should use a DOM parser like requinix suggested, but if you really must go the regex route, this will work and is fairly flexible: $expression='#(id\s*=\s*["\']Qform__FormState["\'][^>]*)?([a-z0-9]{32})(?(1)|[^>]*id\s*=\s*["\']Qform__FormState["\'])#i'; This will allow for some format variation tolerances: random spacing, order of attributes, and quotes. The matched hash will be in $match[2]
  8. If you are certain it will always be a simple paragraph tag (no attributes) then you can use str_ireplace, as it is technically more efficient. $content =str_ireplace(array('<p>','</p>'),'',$content); If it may possibly have attributes, you can use preg_replace instead. $content = preg_replace('~</?p[^>]*>~i','',$content);
  9. If you want to donate to phpfreaks and don't care about getting any forum benefits, you can donate here (note: this page also shows a link to the original forum subscription which as mentioned above, is currently awol). But if it were me, I'd hold off and get some perks
  10. I grew up in Texas, I don't live there now.
  11. But hold off until next time I'm actually down there!
  12. well i don't see any logic in your code that would specifically write to the file twice, so that leaves 2 possibilities: 1) you are using fopen with the 'a' argument, which opens the file and puts the pointer to the end of the file. Basically that means you are appending to the file. So, perhaps it's not really "double writing," but just writing once to a file that already had previous data from some previous test or w/e? 2) Somewhere else is calling your script twice.
  13. Yup, same. 99% figuring out wtf they want, how much should be charged, timelines, misc project management, followup communications/billing, etc.. 1% actual sit down and code.
  14. Okay well, you still aren't being terribly helpful. I'm not much of a css person so I don't know all the syntax rules/possibilities for image URLs in a css file. Never assume that the context you are working with is common knowledge... Having said that..having a quick look at the "example" you provided, I would go with this: /url\s?\(([^)]*)/gi
  15. Anybody who actually does this sort of thing for a living (freelance or employee) knows there is a lot more to it than just sitting down and writing the code.
  16. To be clear, there is no way to have a single string returned with the preg_xxx functions, because that's not how they work. There's nothing particularly magical or mysterious about using $result[1] vs. $result (as a string), but if you insist, you will have to do something like $result = $result[1]; after the preg_xxx call.
  17. Sidenote: quotes are not a very good pattern delimiter to use. They come up often in patterns so it causes extra unecessary escaping, used as string delimiters so may cause issues with writing the pattern correctly to begin with, etc.. so as a best practice, you should use an uncommonly used symbol for your pattern delimiter. I personally favor the tilde ~ because it has no special meaning for anything and stands out quite nicely. $quote = preg_replace("~<ol>(.*?)<li>~s", '', $quote); // first 2 tags
  18. .* is a greedy matchall, so it will match everything it can and then start working its way backwards, only giving up what it has to, to meet the rest of the pattern requirements. What you want is a lazy matchall: '(.*?)' This will only match up to first time it needs to match to fulfill its requirement. Alternatively, you can use a negative character class: '([^']*)'
  19. it would help if you gave example content and exactly what you are trying to get out of it.
  20. If you are looking for that much storage space, perhaps you should instead look for a deal on an external hard drive? They won't fit as easily in your pocket, but you'll get a lot more bang for your buck...
  21. You see what I did there? Cuz an I is really a 1!! aHAHAHAHahahAHA
  22. so if roman numerals are letters, does that make romans the original leetspeakers?
  23. yah i figured...didn't think you busted that out within minutes as a specific response! Was just sayin' in general if we were to do it...
  24. well for starters, we could water that down, since post count should never be a negative number or have decimals.
×
×
  • 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.