Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. .net framework has a microsoft created regex library, but it requires me to either program through their visual studio or use c# express. Doesn't seem to be available for vc++ unless I have the actual visual studio :/
  2. Hey all, So I'm currently trying to learn visual c++, using microsoft's visual c++ express ide. Am I wrong, or does vc++ not seem to have regex capability built into it? That's the impression I'm starting to get...so apparently I need to find a regex library or something, and I thought it would be really super awesome if I could use the pcre library, but apparently that's only officially released for *nix... So basically my overall goal here is I need to be able to do some regex stuff so can someone point me in the right direction? Ideally A direction that involves being as close to pcre as possible, but if that's not an option, it's all good.
  3. ~ ... ~ does the same thing as your / ... / does: they are delimiters. PHP accepts lots of things as the delimiter. I usually use ~ because it doesn't come up inside the pattern a whole lot so I don't have to make sure I'm escaping it. / is used in patterns a lot because regex is usually popular with scraping webpages, and / is a common symbol in webpage code, so when you use / ... / as the delimiter, you end up having to escape shit a lot. Because you are telling it to first match a literal |, then 1 or more word characters (as defined by your locale, not necessarily just [a-zA-Z0-9_], and then you have a negative lookbehind, so after \w+ can't match anything else, the engine steps back 3 characters to make sure whatever was matched by \w+ doesn't end in 'one' or 'two'. So in other words, you were doing it backwards. What you really wanted was a negative lookahead: \|(?!one|two|three|four)[a-z0-9]{1,4} which says: Okay, first let's match a |. After that, we are going to look ahead and make sure the next thing in the string after that | is not a "one" "two" "three" or "four". If it's not, then let's look to see if we can match 1 to 4 a-z0-9 chars (case insensitive because of the i modifier) after that pipe. The main thing to grasp here is that lookarounds have zero width assertion. What this means is that it will look for the (non)match, but it doesn't actually move the position of the pointer forward/backward. This is the main thing that causes people to trip on lookarounds.
  4. ~\|(?!one|two|three|four)[a-z0-9]{1,4}~i
  5. use (.*?) instead of (.*) but you will then find yourself having another problem with your preg_replace in that preg_replace well go through and replace all of them at once in one go. That's why I have a loop, using the additional arguments to limit preg_replace to 1 replace at a time. You also wanted to have the query string id increment so that's thrown in there too. My posted code is also based off the h1 tags. You never clarified whether you wanted to keep the 'h1' tags and linkify them, or replace the h1 tags with the 'a' tags. If you are wanting to keep them and linkify them, I'm pretty sure my previously posted code does what you want. Did you try it?
  6. the answer is to team up with companies that provide software and hardware for listening to the music. Strike a deal with apple to offer a year subscription to music w/ purchase of an i.* sort of thing.
  7. I do admit that it's pretty annoying that I can't somehow pause/rewind songs on last.fm
  8. I don't think spotify has been launched yet in the US, but this kind of thing might really work. It's a streaming music service supported by adverts. You can play as much as you like and get an advert around every 8-10 songs, and i think they aim to tie them in with the end of an album if possible. Less adverts than a radio station and you get to choose the music. Or you can pay to have the adverts removed and it becomes more like your regular subscriptions service. It's certainly enjoying a lot of usage here in the UK. And i'm not surprised really...it's less effort to stream something and start listening instantly than it is to download, the library is pretty large and the adverts really aren't all that intrusive. I'd imagine there's pretty decent potential for advert revenues too. Targeted advertising is always a better and i'd imagine you could get a fairly accurate idea of a listener's demographic from the music listening history. I'll look into that one. Right now I am currently enjoying last.fm It's a free service, supported by ads, as well as revenue based on offering accessibility to buy. They have a huge database of songs. You can listen to the full version of songs up to like 5 times per song or something. After that, you can listen to a 30s clip of it. They also have radio stations and suggestions etc.. meant to help expose you to other artists/songs you might like, based on what you listen to and how you rate it. So far I'm loving this site, as I have quickly found a ton of stuff I would have otherwise never heard of.
  9. Well yeah, I definitely agree that that's what they are shooting for. The point though is that it won't work. Why? Sure, they may be able to scare one or two people, but what about the rest of the millions of people, not to mention the millions of people outside of their jurisdiction? As technology progresses, the need for data to be able to be abstracted away from the process and flow freely is imperative. This is why things like open-sourced solutions are growing, and the e-world is slowly but surely moving away from product-based sales and more towards service-based sales. The Music Industry is going against the grain; trying to paddle upstream when everybody else in the boat is paddling the other way. They may stop a handful of people, but they will never stop the masses, and they will never stop the progression of technology. They are fighting a war they cannot win. The smart thing would be for them to adapt. Offering things like subscription based music listening or downloading songs cheaply on an individual basis is a step forward (though not the ultimate ideal solution). Suing and winning thousands and hundreds and millions of dollars from average Joe is not. It's a waste of time, as they will not see that money anyway (average Joe cannot pay it, and will either file bankruptcy or else take whatever punishment happens when you don't pay, because bottom line is, average Joe does not have that kind of money). People will look at this guy as a vigilante or martyr to the cause, not as an example of what not to do. The Music Industry is shooting themselves in the foot.
  10. how about a beer-to-peer help website, instead?
  11. use gevan's. it's the same principle as mine but he filled in the blanks
  12. select sum(quantity) as total from table where title='...' and size='...' order by date desc may possibly need a group by in there.
  13. Alternatively... $length = 30; $string = "some random long line of text"; $string = wordwrap($string,$length); $string = explode("\n",$string); $string = $string[0] . "...";
  14. alternative to js is to use target="_blank" in your anchor tag. This will only create a full sized window (or tab, depending on user's browser settings). If you are wanting to control size, you're still stuck with js.
  15. I would not classify this with those lawsuits. I'm not saying the "Music Industry" does not have a legit case. What I am saying is that This "making an example" out of individuals is not going to solve the problem, so all they are doing is making an example of how they would rather rape individuals than get with the program.
  16. http://finance.yahoo.com/news/Jury-awards-675K-in-Boston-apf-3221597159.html?x=0&.v=28 This is ridiculous. Does the "Music Industry" really think that financially ruining individuals is going to stop the file sharing "problem"? Bending over and raping a single person like this is not going to make this "problem" go away. When are they going to realize that they need to just buck up and change how they go about doing business, to accommodate technology?
  17. I don't really understand what you mean by adding text between results. Do you mean you want to print other stuff out in each loop iteration? Just put it in there...if that's not what you mean, post code example of what you were doing before.
  18. trim does what it does, regardless of the string you feed it. If something is "not working" then there's something else going on. Maybe you are doing a case-sensitive string comparison and you aren't entering it in right or something. Who knows?
  19. okay the reason why you are getting a bunch of commas is because in you didn't change the part of your code where you are outputting the results. Instead of this: print $row['name'].", ".$row['name2'].", ".$row['name3'].", ".$row['name4'].", ".$row['name5'].",".$row['name6'].", ".$row['name7'].", ".$row['name8'].", ".$row['name9'].", ".$row['name10']."<br>"; do this: print $row['n'] . "<br/>"; Yes, you can post links to your code, but don't ask to have them removed later, because we won't.
  20. $query = "SELECT CONCAT('',name,name2,name3,name4,name5,name6) as n FROM $usertable HAVING n LIKE '%$name%'";
  21. do { $mytext = preg_replace('~(<h1>)(?!<a)(.*?)(</h1>)~i',"$1<a href='?id=".++$id."'>$2</a>$3",$mytext,1,$replaced); } while ($replaced > 0);
  22. edit: What I meant to say was, trim it before the base64_encode trim
  23. You know, I'm also wondering if we are making this more complicated than it needs to be. Is the goal here to extract a number from a string, regardless of where that number is? Is there a reason you can't just do /[0-9]+/ ? It would help if you actually posted an example of the actual content.
  24. well..this is what I came up with. Though the number will appear in $Matches[2] either way, not $Matches[1] preg_match('/(?:(Some )?([0-9]*)(?(1)| Some) Text)/', $SomeString, $Matches);
  25. that can be interpreted at least 3 different ways. I heard a rumor that the more specific you are about your question, the more likely people are going to (?:be able to)? help you. 1) match but not capture change that part to (?:[A-Za-z*) 2) match anything but that (negated char class) change that part to ([^A-Za-z*) 3) not look for it at all remove it from your pattern
×
×
  • 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.