locked
Counting specific links on an external URL RRS feed

  • Question

  • User-956525542 posted
    I need a function, that's able to count the number of links to a specific file type i.e. jpg files on an external url... The url and the type is typed into two textbox... and the system should do the count... If the type entered is .jpg and the url contains 5 ImageDescription tags, the function should return 5. Can anybody give me a clue how to do this
    Sunday, April 18, 2004 5:56 AM

All replies

  • User-1645088262 posted
    erm ... not sure if I understand the question completely but a regular expression may be what you need. You can do a match for the pattern you are after (with the appropriate extension) and it will tell you how many matches have been returned. Have a look at "Expresso" (http://www.ultrapico.com/) and "Regulator" (http://royo.is-a-geek.com/iserializable/regulator/) for good tools to help test / develop the expressions. I think Expresso has some examples of finding links / URLs in it. Regulator links to www.regexlib.com which is a library of existing expressions that may be a good place to start looking too.
    Sunday, April 18, 2004 1:27 PM
  • User-956525542 posted
    I'm pretty confused about this regex thing.... Can anybody help with one that does the right thing?
    Sunday, April 18, 2004 5:02 PM
  • User-956525542 posted
    I've tried this one: ] The problem is, that it grabs all image links, no matter which extension they have
    Monday, April 19, 2004 5:07 AM
  • User-1645088262 posted
    Try this: It assumes no spaces in the "href=" bit and also that the attribute will have quotes round it. Basically, the match is: Hope this helps
    Monday, April 19, 2004 8:14 AM
  • User-956525542 posted
    I've tried this: On the text: On http://www.regexlib.com/RETester.aspx It returns zero results :o/
    Monday, April 19, 2004 8:31 AM
  • User-1645088262 posted
    That should pick up a match but the example you have just given is different to the initial example. If you want an expression that will pickup IMG elements contained in A elements then that will be a bit more complicated. You need to be clear on what should be matched. Is it a link *to* an image or a link that is *displayed* as an image?
    Monday, April 19, 2004 9:27 AM
  • User-956525542 posted
    It's a link displayed as an image linking directly to another image file
    Monday, April 19, 2004 9:38 AM
  • User-1645088262 posted
    Ok, so for your example: Only the first link should be returned ?
    Monday, April 19, 2004 10:39 AM
  • User-956525542 posted
    Exactly :)
    Monday, April 19, 2004 10:55 AM
  • User-1645088262 posted
    Ok, how about this: .*? It matches the '' part and also returns the 'test.jpg' (from the href attribute) as a named match.
    Monday, April 19, 2004 12:47 PM
  • User-956525542 posted
    Did you try that one on http://www.regexlib.com/RETester.aspx It tells me, that there's a syntax error
    Monday, April 19, 2004 1:14 PM
  • User-1645088262 posted
    I tried it using the regulator tool. It may be the syntax for the named capture - some expect <name> instead of 'name'
    Monday, April 19, 2004 3:32 PM
  • User-956525542 posted
    .*? doesn't work eighter... Still generates a syntax error
    Tuesday, April 20, 2004 5:16 AM
  • User-1645088262 posted
    I suggest you use one of the other tools to test it as it seems to work fine with those.
    Tuesday, April 20, 2004 7:59 AM
  • User-956525542 posted
    Allright.... I tried it with Expresso.... Works without syntax errors, but it seems, that it finds more than just the image links.... For example the link below will be included in the result: Test
    Tuesday, April 20, 2004 8:45 AM
  • User-1645088262 posted
    You may need to play about with it a bit. I suspect some of the matches need to be "Zero or more" rather than "One or more", esp after the bit matching the href="target" bit (before the '>' character.
    Tuesday, April 20, 2004 5:09 PM