Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. well yeah, it's pcre but they could have still made the modifiers a separate argument and use the same syntax. They could have easily made the preg_xx functions have no delims, wrapped in quotes, modifiers as seperate argument, and build it internally for the regex engine.
  2. main reason is that for whatever reason the php devs opted to have modifiers inside the regex string instead of as a separate argument, so it needs to have the delimiters so it can know pattern from modifiers.
  3. You are echoing the substr out in the function so that gets evaluated. Instead of echoing in the string inside the function, return it.
  4. When you say you are trying to insert multiple values into a textarea, what are you using as a delimiter? In order to make the posted info into an array, you need to explode at whatever delimiter you are using in the form (like a comma or \n if pressing enter after each one, etc...)
  5. trying to use an element in an array that doesn't exist.
  6. haha oops, can't believe I missed that
  7. okay so since you are wanting to replace things, you need to remove the ^ and $ also, doing {1,} is effectively the same as just using +, not that you need it at all in a preg_replace in this instance, since preg_replace will replace all instances anyways. Also, it needs to be a negative character class, since you want to replace anything that is not those characters. $post = preg_replace('/#[^a-z0-9_.-]#i/', '', 'd!@#agsd$%^&*');
  8. Yeah overall I think the DOM approach would be the best solution. One-lining it (mine) vs. speed (thebadbad's) is more of a thought exercise than anything.
  9. oh and also for yours: I wonder if instead of doing a preg_replace, if you were to do $matched = implode('',$matches[0]); preg_match_all('~src\s?=\s?[\'"]([^\'"]*)[\'"]~i',$matched,$matches); that might possibly be faster.
  10. Garet did have one thing in there that we didn't think of: making the quotes around the width optional.
  11. Around here, 99% of the time "spam" is a synonym for advertising. In misc, mostly anything goes, but advertising is not allowed, and topics that already have stickies about them are closed, since they are common enough to warrant stickies about them.
  12. thebadbad: Also want to point out though that even though my pattern is a lot slower, it does provide a lot more breathing room for matching. I suppose DOM still beats me out garethp: ~<img.*?(?:src="(.*?)".*?)?width="?[1-9][0-9][0-9]*"?.*(?:src="(.*?)".*?)?>~ [1-9][0-9][0-9]* will match 10 or higher, not 100 or higher. You would need to use a + instead of *
  13. http://www.w3schools.com/PHP/php_syntax.asp
  14. oh...I saw the subject and thought you needed help coming up with a subject line.
  15. yeah lol... way faster to break it down but what's the fun in that?
  16. preg_match_all('~<img[^>]*(width\s?=\s?[\'"][1-9][0-9]{2,}(?:px)?[\'"])?[^>]*src\s?=\s?[\'"]([^\'"]*)[\'"][^>]*(?(1)|width\s?=\s?[\'"][1-9][0-9]{2,}(?:px)?[\'"])[^>]*>~i',$string,$matches); echo "<pre>"; print_r($matches[2]); This will retrieve the src url for all images with width 100 (whether it is written as 100 or 100px), regardless of the width location, spacing, quoting, or capitalization conventions. edit: doh! I thought it was supposed to be exactly 100; missed that 'minimum'. regex edited.
  17. oops my bad. I was thinking of preg_match at the time. for preg_replace it would be: $string = preg_replace('~(^.+)/.+~','$1',$string);
  18. $string = preg_replace('~(^.*)/~','$1',$string); or a combo of strrchr and str_replace, though it might produce unexpected results...
  19. htmlentities
  20. You made the exact same post in both threads. One of them was over a year old. It's pretty obvious you are searching the forums for relevant threads to advertise your product.
  21. http://nethack.wikia.com/wiki/Main_Page
  22. haha yah the pirate song is cool. my brother made a flash animation to that song a while back, featuring people from a forum he goes to. http://www.crayonviolent.com/pirate.html
  23. haha I dunno why but I LOVE that song. I had it play for almost an hour and my wife unplugged my computer what is lazytown? Are you talking about that kid show with the pink girl and blue guy?
  24. remove the 'e' after the # in your pattern.
  25. You could bing it and find out! jfbi?
×
×
  • 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.