-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
few people code for the money or the fame. If that's what you're hoping to get out of it, it would be better for you to try your hand at something else.
-
if (!preg_match('~password|mysql~i', $key)) . Though there are a couple other differences, basically the main two differences between the posix functions (ereg ones) and pcre functions (preg_xxx) are 1) You need a delimiter around your pattern. You can use pretty much any non-alphanumeric character. In my code above, I use ~ 2) preg_xxx functions do not have separate functions for case-sensitivity. Instead, you use a modifier, which comes after the ending delimiter. Since eregi is case-insensitive, I added the 'i' modifier.
-
the posix regix functions (like eregi) are deprecated. You need to use preg_match instead. If you can find the line of code that uses eregi() and post that line of code, we can give you the preg_match() equivalent.
-
I see a ")" in your 3rd line that shouldn't be there.
-
Most people use a framework like Zend or something, and follow the MVC pattern. Here is a suggested place to start: http://framework.zend.com/manual/en/learning.quickstart.intro.html
-
$strarray = $arrayhist[1]; echo $strarray; // does this have the expected value?
-
Right. As I mentioned, there is no 100% solution. Even if we were to have experts go in and hand-pick answers...even then, due to the nature of the interwebs, those answers are subject to become outdated later. But that doesn't mean we shouldn't try something that has some margin of error. We can plainly see that in practice, most of the time, the most popular or highest voted answers are indeed good answers. AFAIK we're talking about upvotes, like how it is on StackOverflow.
-
I do admit it is pretty fast paced there, and it is hard to get a well thought out answer in before others are posted and voted. However, from my experience there, the best answers do indeed tend to have the most votes
-
No system is ever going to be 100%. Always gonna be some exceptions. But IMO it works pretty damn nicely on sites that do implelent a post voting system. Look at SO
-
Actually, I can just just put the trailing whitespace in the negative lookahead and skip the trim... $pattern = '~fax\s+#\s+:\s+\K(??!\s*from).)+~i'; preg_match($pattern, $subject, $matches); $fax = $matches[0];
-
Here's my take... $pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i'; preg_match($pattern, $subject, $matches); $fax = trim($matches[0]); So first off, since he's just grabbing one number, preg_match should be used instead of preg_match_all. 2nd, to accommodate random fax number formats, I use a negative lookahead and just match everything up to the next "from" and then trim the extra whitespace.
-
TBH I don't really think xyph's regex is necessary. What is your code for? Seems like a syntax highlighter...IMO it's not the job of your syntax highlighter to validate the function name. Or else, your markup regex and validation regex should be two separate things.
-
Character on an american tv series called the big bang theory
-
That's false though. The implication of this would be that noone could learn to understand recursion. You're like a real-life Sheldon, you know that right? right?
-
Rejoice always, pray continually, give thanks in all circumstances; for this is God’s will for you in Christ Jesus.
-
my idea is for you to stop taking on clients if you don't know how to do the work.
-
can't say for certain...would help if you could post link to page you're actually trying to scrape. Perhaps the content is dynamically generated by js or perhaps it is within an iframe not actually on the page you're scraping. But one guess is perhaps your greedy quantifiers are killing it.
-
damn you and your \K salathe, damn you!
-
The error is mostly self-explanatory. You can only do lookbehinds if the pattern you are matching is a fixed length. So for instance, you can lookbehind for "bob" but not "b[^ ]*". The main principle to understand here is that when you want to replace one thing with another, since preg_replace replaces everything that you match, you have to account for the "anchor" or "delimiter" parts of your pattern you use to isolate what you're trying to replace. So for instance, you are identifying the function name by matching for the "function" before it, and the "(" after it. Those are the "anchor/delimiter" parts of your pattern, what you use to identify the part you're trying to replace. You can accomplish it in several different ways. One way is to use zero-width assertion, which is basically a fancy way of saying match but do not actually consume or make part of the matched pattern. This will allow you to not have to worry about the "anchor/delimiter" parts of your pattern. The problem with that though is that look-behinds must be a fixed length. In your particular case, you can "probably" get away with using "function " as the look-behind pattern. But if you wanted to account for arbitrary space between "function" and the function name, it would no longer work, so IMO, using look-behind is not really the "safest" way to go. In general, the "safest" way to go is to just wrap your "anchor/delimiter" portions of your pattern in their own captured groups, and then use them in your replacement argument. So you mostly had it right in the first place. You just need to do a little bit of extra capturing, and use the right capture variables. Also, I changed it to use a negative char class instead of lazy match all because it's more efficient. $string = "function blah () {"; $string = preg_replace("~(function\s+)([^(]+)~i", '$1<span style="font-weight:bold;">$2</span>', $string);
-
Also you may need to clear your browser's cache and file history to see your changes.
-
Best way to test and update scripts on a live site.
.josh replied to freelance84's topic in Miscellaneous
In this context, "dev site" is just a generic term meaning the "development" version of your live site. As mentioned previously, it doesn't really matter where you host the development version of your site - the main point is that it is a separate copy of your live site's files that you can play with. Whether you host that separate copy on the same server or different server or just make a local copy on your own computer doesn't matter. -
well I don't know what to tell you...the only reason you would get that broken image icon is because the browser is making a request to the server and the server can't find it. So your path and/or spelling of the image file is wrong, and that's all there is to it.
-
Best way to test and update scripts on a live site.
.josh replied to freelance84's topic in Miscellaneous
Usually it is done by using a versioning system like svn. Basically you setup a central repository of your files and then check them out to two locations: live site location and dev site location. You can then do development/testing from the dev checkout and when you are happy, you commit your changes back to the repository, and then update your live files from the repository. Strictly speaking, you don't need a versioning system or repository to do this..you can just have a separate duped dev version of your site and then copy directly over to live site once you are happy. But the advantage of svn is that it keeps track of the changes you've done, and you can "rollback" to previous changes. It also allows for more than one person to work on stuff. But anyways, whether or not your dev version of your site is located on the same server or on a separate server or if you choose to have it locally on your own computer is up to you. It's mostly a question of resources more than anything - as in, can your server's diskspace, memory, etc.. handle having it on there. But most individual users and small sites usually just checkout the repo and do development on their own computer, using a LAMP or WAMP stack. Anyways...not sure what you're really asking here... you asked on SO and all of the people there more or less told you the same thing... Are you not understanding what they are saying? Need more details about how to implement a versioning system? -
Did you read the sticky in that forum?
-
Oh man...last year I had saved my vacation days and PTO days for end of year and between them and holiday/weekend days off...I basically had most of December off... lemme tell you...after taking almost a month off work and coming back to the new year when everybody is like "zomg new year, we're resolving to kickass at everything and bust shit out!" ... now that's depressing. My new year's resolution this year was..."Hmm...as much as I like being able to take almost a whole month off...not worth trying to get back into the swing of things...I don't think think I'm gonna do that again..."