Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Wildcard string

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33825
    noahgelman
    Participant

    I’m trying to select a file path of sub-folders in javascript but have the last folder be a wild card. For example:

    site.com/fruit/apple/
    site.com/fruit/banana/
    site.com/fruit/pear/

    So something like:

    ("/fruit/" + * + "/")

    Except I don’t know what to put in the * area to account for the above folders. The folders are dynamic so I can’t just do it by hand

    #84609
    jamygolden
    Member
    #84688
    noahgelman
    Participant

    Hey jamy :]

    That almost works. I need to make sure it’s matched to a sub folder and isn’t just targeting “http://www.site.com/fruit/” but whatever dynamically generated file path inside it is.

    #84715
    jamygolden
    Member

    You could do something like:
    $(‘a[href*=”/fruit/”]’)

    #84716
    noahgelman
    Participant

    Using $(‘a[href*=”/fruit/”]’) would include “http://www.site.com/fruit/” and I dont want that. I only want to select ones that have another sub folder like “http://www.site.com/fruit/xxxxxxxxx/

    #84720
    jamygolden
    Member

    $(‘a[href*=”/fruit/”]’).not(‘a[href$=”/fruit/”]’);

    Select the anchors if they have ‘/fruit/’ but not if it ends in ‘/fruit/’

    #84766
    noahgelman
    Participant

    ah, I see, that totally works. Thanks a lot jamy

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.