-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
[SOLVED] Alphanumeric plus hypens, periods, and underscores.
.josh replied to bundyxc's topic in Regex Help
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. -
[SOLVED] Alphanumeric plus hypens, periods, and underscores.
.josh replied to bundyxc's topic in Regex Help
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. -
[SOLVED] breaking up a string based on a limit of chars?
.josh replied to tjhilder's topic in PHP Coding Help
You are echoing the substr out in the function so that gets evaluated. Instead of echoing in the string inside the function, return it. -
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...)
-
trying to use an element in an array that doesn't exist.
-
[SOLVED] Alphanumeric plus hypens, periods, and underscores.
.josh replied to bundyxc's topic in Regex Help
haha oops, can't believe I missed that -
[SOLVED] Alphanumeric plus hypens, periods, and underscores.
.josh replied to bundyxc's topic in Regex Help
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$%^&*'); -
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.
-
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.
-
Garet did have one thing in there that we didn't think of: making the quotes around the width optional.
-
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.
-
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 *
-
http://www.w3schools.com/PHP/php_syntax.asp
-
oh...I saw the subject and thought you needed help coming up with a subject line.
-
yeah lol... way faster to break it down but what's the fun in that?
-
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.
-
[SOLVED] Cut off everything after the LAST "/" ?
.josh replied to Cory94bailly's topic in PHP Coding Help
oops my bad. I was thinking of preg_match at the time. for preg_replace it would be: $string = preg_replace('~(^.+)/.+~','$1',$string); -
[SOLVED] Cut off everything after the LAST "/" ?
.josh replied to Cory94bailly's topic in PHP Coding Help
$string = preg_replace('~(^.*)/~','$1',$string); or a combo of strrchr and str_replace, though it might produce unexpected results... -
htmlentities
-
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.
-
http://nethack.wikia.com/wiki/Main_Page
-
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
-
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?
-
remove the 'e' after the # in your pattern.
-
You could bing it and find out! jfbi?