Jump to content

joe92

Members
  • Posts

    304
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    UK

joe92's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Not entirely sure what you are looking for but if it's to remove individual attributes using an onclick or onmouseover event you need to be looking at JavaScript, not RegEx. More specifically, element.removeAttribute("attrName").
  2. The flag for any number is \d You should refrain from doing repetition once, {1}, or placing a character class round a single character, [-]. They really are pointless and just mess up your pattern making it harder to bug find. The website I linked to in my previous post is a brilliant tutorial on regular expressions. If you don't understand something about them, like lookbehinds, then just read what it says. You'll find it helps.
  3. I'm slightly confused by what you mean, is it turn = into == but only if it is not part of another operator, i.e. >=? $str = preg_replace('/[^\<\>][\=]{1}/m', '==', '5x11=8x11.5&6.3=6.3'); This part first, just for future reference, can be neatened up quite a bit. You don't need to escape those signs inside the character classes. Just the signs ']', '\', '-', '^' and whatever the closing delimiter is need to be escaped if using literally. Read the paragraph, 'Metacharacters Inside Character Classes', here. The repetition of 1 is also superfluous. You can just get rid of it. You also don't need to add a character class round a single character, =, you can remove that too. That makes the expression quite a bit easier to read: $str = preg_replace('/[^<>]=/m', '==', '5x11=8x11.5&6.3=6.3'); The reason the preg_replace is failing for your needs is because it is matching the symbol before the equal sign rather than just checking whether it exists or not. To fix this you need to use a negative lookbehind. A lookbehind (or lookahead) checks whether or not a character exists in the string but doesn't include it in the match. In this case we want to make sure the characters < or > do not exist before the equal sign. An annoying thing about the lookbehind is that is has to be of fixed length (a lookahead can be of unfixed length). This has tripped me up many a time in the past but I don't think that should be a problem here as it doesn't class alternation as varying length. Meaning we can use: $str = preg_replace('/(?<!<|>)=/m', '==', '5x11=8x11.5&6.3=6.3'); See it working here, http://codepad.viper-7.com/JUYovq. Hope that helps you, Joe
  4. That sounds like an avenue to explore, unfortunately some of these websites are written purely in HTML with CSS and JS so it can't be implemented here. I'm thinking the iframe route it going to be most effective. I just can't think of a way to get the data to a HTML page any other way. Thanks for your help. Joe
  5. I always thought that Google operates on a database type system, wherein the websites are indexed along with other data such as clicks and views and would be searched via the database. This would mean that the cache was an extra but not essential to the workings of the whole system. Although saying that, I am aware that for SEO it's always good to view the cache, and then the plain text file so that you can understand which links are crawled. Thankfully though, that's not my job We deliver the data through a quick ajax request on page load. The data is so small, usually less than 1 kilobyte, that there is no lag in seeing the page load up. The only problem is that Google does not cache this data (all the sites are listed though). I think that is because it reads as plain text hence ignoring JavaScript, but I'm not too sure as Google is immensely complicated. What solution would you suggest for this? Currently, we provide data for about 5 websites so a complete overhaul now is going to be much preferable to a complete overhaul in a months time or even later. What we are thinking at the moment is using iframes and storing the data in small HTML files for the iframes to read which we can post through ftp to the clients server if needed. Joe
  6. Just recently my colleague emailed me rather concerned that a website we provided data for wasn't getting cached by Google properly. I've just spent the last half an hour thinking of a way to solve the problem before coming to an annoying question in my head, which is: What is the point in Google cache? I can see the need for it when regarding static informative websites such as Wikipedia. Being able to view the content if Wiki goes down could come in handy. But when regarding a small dynamically changing website, is there a need to worry about the cache? The data on this website changes on a very regular interval, probably a minimum of once a week. I cannot think of any purpose for google cache other than to view content on a website when said website is down. In fact, I personally have never actually viewed a cache of a website other than this morning after getting the email. Is there some other purpose to the Google cache that I'm missing? Such as related to helping Google categorise, index and retrieve your site? There is all this hype around creating a website perfect for Google's crawlers that we're spending more time worrying about Google than the actual damn site. Haha. Cheers, Joe
  7. Is this what you mean? <?php $testInput = 'Hello, here is my number, 01911222333, or is it 0175522114, or even the mobile, 07520111444...'; /*the preliminary check to see if there is a phone number*/ if(preg_match("/0(1\d{8,9}|7\d{9})/", $testInput)){ /*now match the phone numbers*/ preg_match_all("/0(1\d{8,9}|7\d{9})/", $testInput, $phoneNumberMatches); /*do with it what you will*/ print_r($phoneNumberMatches[0]); } Here it is in action: http://codepad.viper-7.com/OVa6jq
  8. You almost had it. The pattern delimiter's need to be identical, although I would strongly advise against using the squiggly brackets for them. I would suggest the tilde in this case. Try: ~\(Click To Enlarge\)~
  9. This is a much debated topic, and patent law on software varies greatly from country to country. The US grants all software patents, along the lines that 'Everything under the sun made by man is patentable'. Whereas, over here in the UK, software patents are near impossible to get. In researching/applying for one here you will undoubtedly be referred by a solicitor to the 'Aerotel v Telco and Macrossan' case as they themselves don't have a clue. Let's say you invented facebook and you wanted to apply for a patent on the news feed. In the aspects of your patent, you described the layout of the news feed. You have a textarea at the top of the page to add your own news too and below it, all the news from your friends is displayed. Then, as patent law requires it, you go on to describe every detail of how this is achieved. How the database handles incoming data, how javascript manipulates the page to make it look 'real-time'. The whole works. Someone could then come along, read your patent and understand how to make an exact replica of it (as is the entire aim of patents). Then they do. But they put the textarea at the bottom of the page, and your friends news in a div above it (like text messaging on a smart phone). Because you had described the layout in your patent application, they are not actually infringing on the patent per se. Also they used two queries where you had used a left join? Just simple little things like this make infringements hard to prove. This is where it turns into a battle of the bank accounts. If you had enough money, you could take them to court. They would then have to defend themselves. If they won, you could then appeal the decision and take them right back to court. This can go on and on and if you don't have enough money, it will bankrupt you. So, in my opinion, patents on software are worthless. Unless that is, you want one to pretend that you're a 'big-fish'. And this, in my opinion, is a perfectly justifiable reason. If you stick 'Patent Pending' on your website, most 'little-fish' will see this and think you are not worth the hassle. Alongside registered trademarks and copyright symbols everywhere, they won't rip you off.
  10. Ok, I have located the problem and it was nothing to do with CSS or HTML. Somehow the message was being run through nl2br twice. I don't even know where the second call is yet. This just adds a bit more confusion but at least the problem is no longer a problem. Joe
  11. I have a div which is too display text and preserve the white space at the same time. I am using the css declartion white-space:pre-wrap; and setting a width on the div to achieve this. However, if the person enters a newline and submits this, when it is converted to a break line with nl2br and then displayed on screen it is far too big. I have absolutely no idea what is happening. I have attached an image of an example text to demonstrate what is happening. This is the HTML layout: <div id="theMessage$id" class="theMessage"> <div id="pre$id" class="preTag">$message</div> </div> This is the CSS attached too it: .theMessage{ position:relative; display:table-cell; padding:0 0 0 5px; margin:0; } .preTag{ line-height:1em; margin:0; padding:0; min-width:53em; width:53em; max-width:53em; white-space:pre-wrap; white-space: -moz-pre-wrap !important; /* 1999+ Mozilla */ white-space: -pre-wrap; /* Opera 4 thru 6 */ white-space: -o-pre-wrap; /* Opera 7 and up */ word-wrap: break-word; /* IE 5.5+ and up */ } Thanks for any help! Joe P.s. This is the html markup copied and pasted from firebug of the message from the attached image: <div id="theMessage911" class="theMessage"> <div id="pre911" class="preTag"> Here is a large paragraph of text to demonstrate how the newlines are too large. I have no idea what is causing the newlines to become so large but I have a feeling it is the fact that we are preserving white space by using the css, white-space:pre-wrap;. If I now end this paragraph and press enter once the gap will be too large. <br> See? I only pressed enter once. This is really beginning to annoy me. I have tried all sorts of fonts and the problem remains. I have line-height:1em; within my css also. What is happening? </div> </div>
  12. That's exactly what I'm looking for. Worked like a charm. Thank you!
  13. <?php //get the messages from the database $messagesID_query = mysql_query("SELECT messageID, posterID, messageTime, message FROM chat_messages ORDER BY messageTime DESC LIMIT 5 "); I am currently using the above query to get the last 5 messages from a message log. Say we have 45 messages, the query will pull them out like so: 45, 44, 43, 42, 41 I then need that order flipped so that I can display the newest message (id, 45) at the bottom of the message box by simply accessing it last. Like so: 41, 42, 43, 44, 45 Is there a way I can do all of this in one go with mysql with no need to use any php functions afterwards? I am currently using two loops. One to reverse the order, and another to print the messages in the desired fashion. Many thanks, Joe
  14. That is possibly the best $ to GB ratio SSD around at the moment that I have seen. Get it. I installed a 60GB OCZ SSD (this one to be precise) as a primary drive in a computer for a colleague of mine and the speed increase is phenomenal. SSD's might be expensive but when you can get from stone cold off to checking your emails within 30 seconds, it soon pays off I think. However, if you're looking to save a bit of money, do as I did for my colleague. I installed the cheaper 60GB SSD for him as the primary drive and then a 500GB HDD (half the price of the SSD) as a secondary drive. The operating system and all programs are installed on the SSD and all the files are saved to the HDD. The computer is incredibly fast. Then again, if you aren't too bothered about saving money and want a really fast computer, you could still run that set-up described and then spend the money you saved (plus a little extra) on an intel i7-2600k CPU. But yeah, that is definitely a good SSD you have found. Comes in at just over a dollar a GB, which for an SSD these days is very good value. Also, I know for a fact that Corsair are one of the best for producing RAM, so it goes to say that they should also be good for SSD's. They're practically just large RAM chips Joe
×
×
  • 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.