# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r".*images\/(?!cached).*"
test_str = ("./images/logos/partners/mastergen.png\n"
"./images/logos/partners/highland.png\n"
"./images/logos/partners/charollais.png\n"
"./images/logos/partners/grasstec.png\n"
"./images/logos/partners/stabiliser.png\n"
"./images/logos/services\n"
"./images/logos/services/farmpay-icon.png\n"
"./images/cached\n"
"./images/cached/.DS_Store\n"
"./images/cached/logo-farmpay-black.png\n"
"./images/cached/logo-green-text.svg\n"
"./images/cached/readme.md\n"
"./images/cached/logo-green-icon.svg\n"
"./images/cached/logo-green-icon.png\n"
"./images/cached/logo-farmpay-white.png\n"
"./images/cached/logo-white-text.svg\n"
"./images/cached/logo-green.png\n"
"./images/user\n"
"./images/user/.DS_Store\n"
"./images/user/shield.svg\n"
"./images/user/shield-error.svg\n"
"./images/user/test-delete.png\n"
"./images/user/locked-avatar.png\n"
"./images/user/unknown-avatar.png\n"
"./images/listing-photo-guides\n"
"./images/listing-photo-guides/goats\n"
"./images/listing-photo-guides/goats/.DS_Store\n"
"./images/listing-photo-guides/goats/bad\n"
"./images/listing-photo-guides/goats/bad/1.png\n"
"./images/listing-photo-guides/goats/good\n"
"./images/listing-photo-guides/goats/good/1.png\n"
"./images/listing-photo-guides/pigs\n"
"./images/listing-photo-guides/pigs/.DS_Store\n"
"./images/listing-photo-guides/pigs/bad\n"
"./images/listing-photo-guides/pigs/bad/2.png\n"
"./images/listing-photo-guides/pigs/bad/1.png\n"
"./images/listing-photo-guides/pigs/good\n"
"./images/listing-photo-guides/pigs/good/2.png\n"
"./images/listing-photo-guides/pigs/good/1.png\n"
"./images/listing-photo-guides/.DS_Store\n"
"./images/listing-photo-guides/dairy-cattle\n"
"./images/listing-photo-guides/dairy-cattle/.DS_Store\n"
"images/listing-photo-guides/dairy-cattle/bad\n"
"./images/listing-photo-guides/dairy-cattle/bad/2.png\n"
"./images/listing-photo-guides/dairy-cattle/bad/3.png\n"
"./images/listing-photo-guides/dairy-cattle/bad/1.png\n"
"./images/listing-photo-guides/dairy-cattle/good\n"
"./images/listing-photo-guides/dairy-cattle/good/2.png\n"
"./images/listing-photo-guides/dairy-cattle/good/3.png\n"
"./images/listing-photo-guides/dairy-cattle/good/1.png\n"
"./images/listing-photo-guides/sheep\n"
"./images/listing-photo-guides/sheep/.DS_Store\n"
"./images/listing-photo-guides/sheep/bad\n"
"./images/listing-photo-guides/sheep/bad/4.png\n"
"./images/listing-photo-guides/sheep/bad/2.png\n"
"./images/listing-photo-guides/sheep/bad/3.png\n"
"./images/listing-photo-guides/sheep/bad/1.png\n"
"./images/listing-photo-guides/sheep/good\n"
"./images/listing-photo-guides/sheep/good/4.png\n"
"./images/listing-photo-guides/sheep/good/2.png\n"
"./images/listing-photo-guides/sheep/good/3.png\n"
"./images/listing-photo-guides/sheep/good/1.png\n"
"./images/listing-photo-guides/breeding-cattle\n"
"./images/listing-photo-guides/breeding-cattle/.DS_Store\n"
"./images/listing-photo-guides/breeding-cattle/bad\n"
"./images/listing-photo-guides/breeding-cattle/bad/4.png\n"
"./images/listing-photo-guides/breeding-cattle/bad/2.png\n"
"./images/listing-photo-guides/breeding-cattle/bad/3.png\n"
"./images/listing-photo-guides/breeding-cattle/bad/1.png\n"
"./images/listing-photo-guides/breeding-cattle/good\n"
"./images/listing-photo-guides/breeding-cattle/good/4.png\n"
"./images/listing-photo-guides/breeding-cattle/good/2.png\n"
"./images/listing-photo-guides/breeding-cattle/good/3.png\n"
"./images/listing-photo-guides/breeding-cattle/good/1.png\n"
"./images/listing-photo-guides/store-cattle\n"
"./images/listing-photo-guides/store-cattle/.DS_Store\n"
"./images/listing-photo-guides/store-cattle/bad\n"
"./images/listing-photo-guides/store-cattle/bad/2.png\n"
"./images/listing-photo-guides/store-cattle/bad/1.png\n"
"./images/listing-photo-guides/store-cattle/good\n"
"./images/listing-photo-guides/store-cattle/good/2.png\n"
"./images/listing-photo-guides/store-cattle/good/1.png\n"
"./images/backgrounds\n"
"./images/backgrounds/auctions.jpg\n"
"./images/backgrounds/family-cows.jpg\n"
"./images/backgrounds/tablet-livestock.jpg\n"
"./images/backgrounds/dna-strand.jpg\n"
"./images/backgrounds/apps.jpg\n"
"./images/backgrounds/.DS_Store\n"
"./images/backgrounds/handshake-livestock.jpg\n"
"./images/backgrounds/cows.jpg\n"
"./images/backgrounds/sheep.jpg\n"
"./images/backgrounds/premium-seller.jpg\n"
"./images/backgrounds/handshake-trade.jpg\n"
"./images/backgrounds/haulage-trailer.jpg\n"
"./images/backgrounds/uk-map.png\n"
"./images/backgrounds/vet.jpg\n"
"./images/team\n"
"./images/team/kate-jones.jpg\n"
"./images/team/michelle-shores.jpg\n"
"./images/team/dan-luff.jpg\n"
"./images/team/.DS_Store\n"
"./images/team/sam-scott.jpg\n"
"./images/team/andrew-loftus.jpg\n"
"./images/team/ben-stanley.jpg\n"
"./images/team/rosie-hetherington.jpg\n"
"./images/team/derek-lewis.jpg\n"
"./images/team/peter-ellis.jpg\n"
"./images/team/andrew-huxham.jpg\n"
"./images/team/alex-crooks.jpg\n"
"./images/team/bertie-steggles.jpg\n"
"./images/team/jamie-mcinnes.jpg\n"
"./images/team/patrick-bidwell.jpg\n"
"./images/team/dave-rose.jpg\n"
"./images/team/becky-smith.jpg\n"
"./images/team/andrew-connon.jpg\n"
"./images/team/karen-johnson.jpg\n"
"./scss\n"
"./scss/config\n"
"./scss/config/_variables.scss\n"
"./scss/vendor.scss\n"
"./scss/components\n"
"./scss/components/blog.scss\n"
"./scss/components/button.scss\n"
"./scss/components/table.scss\n"
"./scss/components/forms.scss\n"
"./scss/components/layout.scss\n"
"./scss/components/tag.scss\n"
"./scss/components/tooltip.scss\n"
"./scss/components/typography.scss\n"
"./scss/components/animations.scss\n"
"./scss/components/utility.scss\n"
"./scss/components/loading.scss\n"
"./scss/app.scss\n"
"./native-app\n"
"./native-app/generated\n"
"./native-app/generated/.DS_Store\n"
"./native-app/generated/ios\n"
"./native-app/generated/ios/splash\n"
"./native-app/generated/ios/splash/Default-568h@2x~")
matches = re.finditer(regex, test_str)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html