-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
It's a regular expression, or regex, for short. Pattern matching. The pattern says look for one or more spaces or tabs in a row and replace it with a '+'. The \s stands for the space or tab. The + is the quantifier: 1 or more of the previous thing (the \s). The ~...~ are delimiters, signifying the start and end of the pattern. The 2nd argument of the preg_match function is what you want to replace what is matched in the pattern with. In your case, you want to match every instance of 1 or more space/tab chars in a row with a plus sign.
-
There are no good articles on that. That's the art of coding. It comes with experience. The more you code, the more you look at it and say hey, there's no reason these two things can't be combined, or maybe you come across in the manual some function or something that happens to already do what those 5 lines of code you wrote out the hard way does. It's pattern recognition. There's nothing to memorize about it. It's a skill that comes with experience.
-
Simple validation script works in all browsers I tested except IE6
.josh replied to sKunKbad's topic in Javascript Help
We rarely get clients bitching about IE6 incompatibility at the company I work for. But, my dept isn't really far enough up on the totem pole to tell them so the hell what, so we usually do have to cater to it when it comes up. Some of us use http://www.xenocode.com/Browsers/ Some of us use http://www.microsoft.com/downloads/details.aspx?FamilyID=8e6ac106-525d-45d0-84db-dccff3fae677&displaylang=en -
not to mention the fact that doing javascript validation is useless. Humans can just disable it. Bots just ignore it.
-
$string1 = preg_replace('~\s+~','+',$string1);
-
ah yeah, the undefined var notice. It's not strictly necessary to pre-assign a var like that with php. It just "let's you know" that that's what you're doing. I always forget about that because I have it set to not report notices. and yeah, sorry, forgot about removing the image/ in the echo since it would already be there from the glob. and on that note, you're probably going to want to change the href to use basename($file) instead of just file.
-
<?php $files = glob('images/*.jpg'); foreach ($files as $file) { echo ($count % 4 == 0)? "<br/>" : ""; $count++; echo "<a href=\"img.php?file=$file\" /><img src=\"images/$file\" width=\"100\" style=\"border:1px solid #e96302;\" /></a>"; } ?>
-
Well if we want to play the semantics game, "the time minus 30 minutes from now" would actually be expressed as time() - (time() + (30*60))
-
i forgot to add single quotes on $_GET['s'] , but it doesn't change anything..there is still error I'm sorry, what I meant to say was, did you echo $start to see what it's holding? I understand how one could have been confused by what I said before.
-
did you echo $start to see what it's holding?
-
[SOLVED] How to strip our Accent Characters from text string?
.josh replied to fatmikey's topic in PHP Coding Help
well that's why I opt for the opinion to tell the user that non <insert good stuff here>'s are not allowed, and let the user pick an alternative. -
tang is suggesting you append the id to foo, so it will end up looking like id="foo123"
-
[SOLVED] How to strip our Accent Characters from text string?
.josh replied to fatmikey's topic in PHP Coding Help
I agree with the "don't just strip them out". If you are wanting to stick with the "get rid of them" instead of "make sure they display" route, I would give the user the option to enter in something of the "correct" format, rather than you "stripping" them out. Check if they are there, tell the user he can't use them, re-enter name, sort of thing. if(!preg_match('~^[a-z ]+$~i',$name)) { // name has more than a-z, A-Z or space, give error } -
pass the id back and requery?
-
For real. I grew up in texas. Look how off-key I am.
-
Bastard, got something to say about Texas? Naw, I ain't got nuthin' ta saay.
-
Okay well then I'm sorry, I can't give you any more specific help. According to your OP you said: That pattern starts at the beginning of a line and looks for that exact string, matching everything to the end of that line. If print_r($match) is not showing anything then $outputtext does not contain what you think it does. That could be because your script does not properly assign the content to it, or it could be that the info you supplied about the context is bogus. As in, maybe "Password:" isn't really at the beginning of the string, or maybe that's not how it's spelled (even case-sensitive). I'd start out by echoing $outputtext to see if it has data in it in the first place.
-
Oh I don't know, maybe the actual subject to which you are trying to scrape the info from might be nice. You know, the context of the situation. That sort of thing helps.
-
-
why would they make a content patch for d2? That game has been out for many years. Unless they are wanting to make it compatible with d3...
-
In my experience I have had adverse side effects to putting the dash as the last character. For instance, [a-] sometimes the engine will treat it as a or - and sometimes it will treat it as a to anything above it. I haven't fully investigated it, but I swear, I've made patterns that just did not seem to work until I moved the - from the end to the beginning.
-
well damn, I can't believe none of us thought about that. There's no reason why those quantified classes can't just be combined with their respective starting/ending classes, using the + instead of the *. doh! edit: oh wait, I knew there was a reason that was done. the OP said it had to end with a letter, so the end of the pattern had to have 2 separate classes. No reason the first one can't be combined though... also, you forgot the ? after the [_-] as OP said it's optional (also it should be [-_]. - should always come first in a class unless you want a black hole to open up and swallow the universe). preg_match('/^[a-z\d]+[-_]?[a-z\d]*[a-z]$/i',$string); and of course, we could, as before, debate about whether to make the + greedy or not.
-
you go into the real world and interact with real people on the trial WoW. It's limited though. You can't give or receive items from people, etc.. and I'm not 100% but I think there is a level cap somewhere around level 10-20. And the only time lowbies like dueling each other is maintenance day and their server is down and they make temp chars on other servers and duel each other or go do a lowbie raid on a cap city or something. I played WoW for almost 4 years. I dropped my subscription about 2 months before WotLK came out. I went and downloaded the 10 day trial for that and did some of the quests on a couple of my level 70's. Didn't upgrade to full subscription. I got a lot of enjoyment out of it or at least passed a lot of time playing it, but it just doesn't appeal to me anymore. More and more they are catering to the PvP crowd, because that's where the money is at these days. But it's totally ruining the PvE experience. On the one hand, I do agree, but on the other hand, I don't really think bliz really relies too much on completely new customers anymore. It's been a very long time since I've someone say "hey, I've never heard of this game before, it looks cool, I think I'll try it." It's always someone being coerced by their friend(s) to get into it. So bliz doesn't really need to care about showcasing the big stuff. They already have their current customers doing it for free on their own accounts or by word-of-mouth. Give a 10-day trial starting out as a newbie, their high level friends act as their personal (non-paid) customer service representative, personally walk them through the setup, kill everything in site for them in one blow, promises to power level them to a decent level, blahblahblah, and voila, new customer. battle.net: Yes, the starcraft, warcraft (except for WoW) and diablo series could be played online on battle.net and it was (still is) free. I've read a lot about how there will be a lot of changes to battle.net to accommodate when d3 comes out, but nothing specifically mentioned one way or the other whether they will charge. Considering d3 will be the same as d2 and d1 in that you can play offline and you can also directly connect to friend's computers and play multiplayer, that's a good argument that it will continue to be free. On the other hand, seeing as how bliz has gone from a company claiming it's all about the lore and pve and would never sellout, to, well, selling out, I wouldn't be surprised if they did charge for it. And fail. People will just make their own sites that do the same exact thing. People will just go there, find parties, designate which person's computer is the server, and play together directly. starcraft, diablo and warcraft series are multiplayer games, not massive multiplayer games.
-
pshh...I just go visit my redneck relatives down in Texas. They make big ass bonfires in the middle of their field. Wrap the stuff in foil and toss it in. Get really drunk. Lots of accidents from trying to pull it out, after said drinking. Good thing most of them are RN's and paramedics...
-
oh and btw, millions of people do that all the time. It's called bbqing. Sure, you got your fancy do everything grills, but many people swear by the minimalist approach.