Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. @JAY6390: I'd probably use \s* instead of \s+? because you don't technically need a space. But even if at least one space was certain, you don't actually need that ? as all it does is make it lazy, not optional, and it's matching something specific, not a wide range (like a dot). Also, your char class only has lowercase a-f. Since capitals are allowed, you either need to throw A-F in there or use i modifier. Also, {3,6} probably won't work either...that would allow for instance 1234 which is not valid...would probably need to instead use alternation like ~\bcolor:\s*#([0-9a-f]{3}|[0-9a-f]{6});~i and one last thing, i'd consider wrapping that whole thing in matching for <...> or style="..." to more specifically put it onto a context where you'd find it.
  2. yeah, was just nitpicking you don't even need to setup a js regexp object if it's a straight pattern, only if you want to throw a variable into the mix as part of the pattern.
  3. @gizmola: preg_match() is a php function, he is asking about javascript. But that does bring up the point of...why are you scraping this page with javascript? There are 100 better ways to get that data.
  4. assuming you actually added the code to the link's onclick correctly, there's another hoop to jump through that GA fails to mention or consider: more often than not, when you click on the link, you wind up getting taken to the download before the GA code has a chance to trigger. See this post for details. Different question, same principle.
  5. Especially to # .37 as only being about a 3rd of a person must make things especially challenging. Thumbs up to you! (If you have thumbs...if not, no offense intended, mr. thumbless person)
  6. post count has always been visible to all. But depending on your rank, it may only show up in the user profile, not on posts.
  7. minor caveat..that would allow someone to enter in "100." (a dollar amount and a decimal but no cents). I don't know how often that would *really* come up but you should be aware that it is possible. You can easily automatically look for and trim it off if it's there instead of making the user jump through that hoop though... Also it would allow for "100.1" (vs. 100.10). Technically the "100.1" is valid and the same according to the computer but most people write it with the 0. Mostly a matter of philosophy but again, just wanted to make sure you are aware that is possible. To fix both of these with the current javascript code, you can change {0,2} to {2} and that will force the user to enter in 2 digits after the decimal. But again, there are ways to fix it where it doesn't involve making the user do it, so yeah...up to you.
  8. as for the code you posted... I didn't fine-tooth-comb it but that looks more like validating user input than securing a session... and for the most part, yes, I would trust it. Looks like it is using mostly straight regex to validate. For instance, preg_match('~^[0-9]+$~',$subj) means to match for 1 or more digits in the complete $subj. While there are a number of built-in php functions that effectively do the same thing, i doesn't get any more cut and dry than that.
  9. I think because most sites that offer different language versions of their pages, don't try to translate arbitrary text on-the-fly from some generator, but instead hire professional translation services, so they are just swapping prefab text to begin with. And IMO that's the better route at this time...translation engines aren't all that great at being accurate... I don't know very many businesses willing to put their trust in them for trying to sell stuff.
  10. I thought Misc. forum also fell under that...has that been changed? edit: Well I just made a post in Misc and it did inc my post count...but I'm pretty sure at one point in time it wasn't like that.
  11. Salatheman
  12. You would think so... but unfortunately that's not usually the case. It's really easy to assume that someone with 10k posts on a help forum might be worth listening to.
  13. oh I thought you were wanting to make your own "back" button, like a link of your own, not the actual browser back button.
  14. depending on the amount of data... file_put_contents or else fopen, fwrite, fclose
  15. look at how your text is highlighted. You used a single quote to open your string but a double quote to close it.
  16. You are right, it is *possible* but... I somehow doubt someone versed enough to make their own webmail client would be asking a question like this. On a side note... dunno how active you are about reading posts in various forums around here, but this seems to be a recurring topic lately. I would almost tentatively call "homework!" but it does seem kind of an odd assignment to be giving....probably just a coincidence.
  17. What about keeping track of it with a session array?
  18. You should know that 213% of online users HATE those "are you sure you want to close this window" popups, NO good EVER comes from them, and if you somehow think your site is the exception and that you actually will have people who will say "omg you're right, I DON'T want to close this window, what was I thinking??" then you should pick another profession right now, because you have just demonstrated utter failure to understand the user base or your own product. If you want to decrease bounce rate on your site, then focus on providing quality, relevant content / products, not trying to trap people into staying on your site or making them jump through some extra hoop to leave.
  19. TIPS for asking a regex question: - give an example of $coord - give an example of expected match - show what it is giving you instead - be more specific than "it's not working"
  20. hmmm...so I went there and... First off, I wonder if it makes sense to link phpfreaks smf with linuxforum smf so we don't have to register a separate account over there? 2nd...I can't seem to even register there...I click the register button and it displays the ToS and when I click to agree to it...it just keeps refreshing the same ToS page, can't move beyond that.
  21. I noticed a couple typos in your OP, so I took the liberty of fixing that right up for you: Your welcome.
  22. okay I think you probably need to step back a minute and figure out what exactly you want to actually do here. You've gone from checking if the string is valid to replacing invalid chars. Those are 2 different things. And you've also randomly changed what you do and do not want to allow... So you have a form field someone fills out: a) what are the accepted values - only letters? letters and numbers? letters, numbers, underscore, space? anything else? minimum and maximum amount of chars allowed? give a full list. b) do you want to kick back an error message if someone enters in invalid chars, or do you want to remove invalid chars? (advice: if you should probably kick back an error message if this is supposed to be for allowing a user to pick a user name - straight up removing invalid chars should only be done for sanitizing purposes).
  23. Well for knowing how to program as a software engineer (or any body else that works directly with programmers) is so that you can speak their language, understand wtf they are saying, move forward on projects, etc... have you actually tried to explain a coding problem to a non-coder before (like for real)?
  24. if(preg_match("/^[0-9]+:[X-Z]+$/D",$str)) that pattern will return true if it finds.. starting at the beginning of the string, there are 1 or more numbers, followed by a literal colon, followed by one or more X,Y or Z characters followed by end of string. So for instance: "323234:YXYXY" true "1:A" false "blah" false also, you make a call to your function but don't actually return true or false, so by default it will always return true, so you will always get that "TRUE" echoing.
  25. okay yah...so the actual replace you are using isn't an actual pattern and doesn't have that global modifier you previously showed, so yeah, it's just a straight string replace, that's why it's only changing the first instance of .com to .co.uk. the better thing for your code to be doing is a replace with an end of string anchor on the hostname instead of full url, and then rebuilding the full url with protocol, hostname, pathname and query string (other js environment variables). This will make it only replace the last instance of the hostname only....however, this doesn't address your issue of wanting to replace any domain suffix with .co.uk which as I mentioned, is an impossible task, because of the sheer size of available suffixes.....unless you only expect a handful of domain suffixes to come up (which I would not bother trying to do unless that list is like 20-50 tops) to match against.
×
×
  • 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.