Jump to content


Member Since 01 Jan 1970
Offline Last Active Yesterday, 07:43 PM

Posts I've Made

In Topic: Some items are already hovered over on page load. Any way to fix this?

27 August 2016 - 06:03 PM

You can try adding something like this. I've seen it more or less work as a bandaid for some:

$(document.ready(function() {
  $('.product-small .show-details').hide();

I don't really have an explanation why it happens though. 

In Topic: Get part of URL and add to specific links

04 August 2016 - 03:58 AM

Here is a basic example for what you want to do, that will work for the link example you provided:

  $('a').each(function() {
    var onclick = $(this).attr('onclick')||'';
    var qs = location.search.replace('?','');
    var url=onclick.match(/window\.open\('([^']+)/);
    if (url&&url[0]) {
      newUrl = url[0] + ((url[0].indexOf('?')==-1) ? '?' : '&') + qs;
    var href = $(this).attr('href')||'';
    if (href) {
      href += ((href.indexOf('?')==-1) ? '?' : '&') + qs;

However, this is generally bad practice, as it can easily break.  The better thing to do would be to move all of the onclick code to a callback function and then attach the callback function with a click event handler.  That way, you can use a variable instead of hardcoded value and then update the variable instead of trying to scrape onclick like this. 


sidenote: your trackOutboundLink() function will never fire because of that return false; before it. 

In Topic: Storing data in a JSON text column

31 July 2016 - 04:54 PM

If you are absolutely, positively, 100% sure you will not ever need to actually do any queries to return data sets based off stuff within there, then it shouldn't be an issue

In Topic: Regex : better solution than ^[0-9]+(,[0-9]+)*$ ?

31 July 2016 - 04:48 PM

Just a random thought.. I don't know full context so this may or may not be something you can do, but I assume if it's a list of numbers you will split at the comma and loop anyways.. why not just simplify to


In Topic: using wildcard to scrape between changing div id

31 July 2016 - 04:39 PM

To directly answer your question, with regex you can use a negative character class to match anything that is not a quote. You didn't actually post your regex code, so a simple example matching relevant part:

preg_match('~<span id="[^"]*">~',$content,$match);

However, I agree with kicken about using a DOM parser.  Depending on what exactly you are looking to grab, you can sometimes get away with parsing html with regex, but in general, regex alone cannot be used to fully and reliably parse html.  Regular expressions (regex) parses regular language types (hence the name), meaning, there is an identifiable pattern to the context.  HTML is a context free language, which means it is not regular.  In order to reliably parse html, you need a combination of regex, loops, conditions, tokens, etc. basically, all the things that make up a DOM parser, which is exactly why we have DOM parsers.