# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?:(\$.*):)"
test_str = ("$application-background: rgba(81, 99, 120, 0.1);\n"
"$application-background-light: #ffffff;\n\n"
"$primary-light: #00a6ff; // rgba(0, 166, 255, 1)\n"
"$primary-light-accent: #1f95f8;\n"
"$primary-lighter: #99dcff;\n"
"$primary-dark: #36436b; // rgba(54, 67, 107, 1)\n"
"$primary-darker: #2b3555;\n"
"$primary-darkest: #191f32;\n"
"$secondary-light: #008aff;\n"
"$tertiary-light: #4f5bff;\n"
"$quaternary-light: #27358c;\n"
"$sub-accent1: #00ea42;\n"
"$sub-accent2: #bedb00;\n"
"$sub-accent3: #ffb428;\n\n"
"$widget-light: #f3f4f6;\n"
"$widget-lightest: #ffffff;\n"
"$widget-disabled-light: #ccc;\n"
"$widget-disabled-lighter: #f9f9f9;\n"
"$navbar-color-default: $widget-lightest;\n"
"$navbar-light-color: #fafafa;\n"
"$sidebar-background: #fafafa;\n"
"$text-light: #516378;\n"
"$text-lighter: #889aae;\n"
"$text-lightest: #cccccc;\n"
"$text-dark: #ffffff;\n"
"$text-dark2: #efefef;\n"
"$text-darker: #dedede;\n"
"$text-disabled: $text-lightest;\n"
"$text-placeholder-dark: $text-dark2;\n"
"$text-navbar-bright: rgba(0, 0, 0, 0.9);\n"
"$text-navbar-bright2: rgba(0, 0, 0, 0.4);\n"
"$text-navbar-dark: rgba(255, 255, 255, 1);\n"
"$text-navbar-dark2: rgba(255, 255, 255, 0.4);\n"
"$border-light: #e8ebed;\n"
"$border-dark: #ccc;\n"
"$border-active: $text-light;\n"
"$border-color-dark: #d9d9d9 $border-dark #b3b3b3;\n"
"$warning: #ffa908;\n"
"$trend-high: #ff3d79;\n"
"$trend-low: #1e98ff;\n"
"$trend-mid: $text-light;\n\n"
"$list-item-selected: rgba(81, 99, 120, 0.2);\n"
"$list-item-hover: rgba(81, 99, 120, 0.1);\n\n"
"$poor: #ff7da5;\n"
"$fair: #ffafc8;\n"
"$average: #ffdfa4;\n"
"$good: #a1d525;\n"
"$excellent: #00d63d;\n\n\n"
":export {\n"
" primaryDark: $primary-dark;\n"
" primaryLight: $primary-light;\n"
" secondaryLight: $secondary-light;\n"
" tertiaryLight: $tertiary-light;\n"
" quaternaryLight: $quaternary-light;\n"
" subAccent1: $sub-accent1;\n"
" subAccent2: $sub-accent2;\n"
" subAccent3: $sub-accent3;\n"
" poor: $poor;\n"
" fair: $fair;\n"
" average: $average;\n"
" good: $good;\n"
" excellent: $excellent;\n"
"}\n\n\n"
"$black: black;\n"
"$black-10: rgba(0, 0, 0, .1);\n"
"$black-15: rgba(0, 0, 0, .15);\n"
"$black-20: rgba(0, 0, 0, .2);\n"
"$black-30: rgba(0, 0, 0, .3);\n"
"$black-40: rgba(0, 0, 0, .4);\n"
"$darker: #152128;\n"
"$darker-40: rgba(21, 32, 40, .4); // rgba($darker, .4)\n"
"$darker-50: rgba(21, 32, 40, .5); // rgba($darker, .5)\n"
"$darker-70: rgba(21, 32, 40, .7); // rgba($darker, .7)\n"
"$darker-80: rgba(21, 32, 40, .8); // rgba($darker, .8)\n"
"$darker-90: rgba(21, 32, 40, .9); // rgba($darker, .9)\n"
"$dark-two-10: rgba(81, 99, 120, .1);\n"
"$dark-two-20: rgba(81, 99, 120, .2);\n"
"$dark: #516378;\n"
"$dark-60: rgba(81, 99, 120, .6);\n"
"$dark-10: rgba(81, 99, 120, .1); // rgba(80, 99, 120, .1) rgba(81, 99, 119, .1)\n"
"$dark-15: rgba(81, 99, 120, .15);\n"
"$dark-30: rgba(81, 99, 120, .3);\n"
"$dark-20: rgba(81, 99, 120, .2); // rgba(80, 99, 120, .2) rgba(81, 99, 119, .2)\n"
"$dark-40: rgba(81, 99, 120, .4);\n"
"$dark-6: rgba(81, 99, 120, .06);\n"
"$gray: #7C858C;\n"
"$light: #98A7B3; // #97A7B4 #97A6B2\n"
"$light-50: rgba(152, 166, 179, .5);\n"
"$lighter: #E8EBED;\n"
"$smooth-sky: #87D5FF;\n"
"$sky: #00E2F5;\n"
"$sky-20: rgba(0, 221, 244, .2);\n"
"$magenta: #FF21A3;\n"
"$magenta-10: rgba(255, 33, 163, .1);\n"
"$yellow: #FFB000; // #FFA908\n"
"$lemon: #EDED00;\n"
"$spring: #4BFF6B;\n"
"$green: #00D63D;\n"
"$cobalt: #00A6FF;\n"
"$cobalt-10: rgba(0, 195, 255, .1); // rgba(0, 165, 255, .1)\n"
"$cobalt-20: rgba(0, 195, 255, .2);\n"
"$blue: #4A4FEB;\n"
"$purple: #9270FF;\n"
"$navy: #1B1464;\n"
"$snow: #F3F4F5; // #F2F2F2\n"
"$snow-68: rgba(243, 244, 245, .68);\n"
"$pale-grey-five: #F5F5F7;\n"
"$snow-60: rgba(243, 244, 245, .6); // rgba(243, 243, 244, .6)\n"
"$warm-grey-10: rgba(119, 119, 119, .1);\n"
"$white: white;\n"
"$white-30: rgba(255, 255, 255, .3);\n"
"$white-50: rgba(255, 255, 255, .5);\n"
"$white-70: rgba(255, 255, 255, .7);\n"
"$midnight: #36436B;\n"
"$midnight-hover: #2B3457;\n"
"$dawn: #5B83FE;\n"
"$dawn-hover: #4864CD;\n"
"$periwinkle: #A98FFF;\n"
"$pastel-purple: #B7A1FF;\n"
"$carolina-blue: #87A5FF;\n"
"$pastel-blue: #9DB5FE;\n"
"$pale-grey: #EEF1F4;\n"
"$warm-pink: #FF3D79;\n"
"$warm-pink-darker: #e6376e;\n"
"$warm-pink-darkest: #c22f5d;\n"
"$warm-pink-15: rgba(255, 61, 121, .15);\n"
"$pale-grey-two: #E8EBED;\n"
"$pale-grey-two-50: rgba(232, 235, 237, .5);\n"
"$pale-grey-two-30: rgba(232, 235, 237, .3);\n"
"$pale-grey-two-70: rgba(232, 235, 237, .7);\n"
"$pale-grey-two-20: rgba(232, 235, 237, .2);\n"
"$pale-grey-two-10: rgba(232, 235, 237, .1);\n"
"$pale-grey-three: #EAEFF4;\n"
"$charcoal-grey: #2B2F35;\n"
"$charcoal-grey-80: rgba(43, 47, 43, .8); // rgba(42, 47, 52, .8)\n"
"$charcoal-grey-90: rgba(43, 47, 43, .9); // rgba(43, 47, 52, .9)\n"
"$charocol-grey-30: rgba(43, 47, 53, .3);\n"
"$silver: #DCE0E4; // #CFD2D4 #C9D0D5\n"
"$silver-two: #D2DADF;\n"
"$silver-three: #C9D0D5;\n"
"$azure: #00A6FF;\n"
"$azure-two: #0095E4;\n"
"$azure-hover: #008AD4;\n"
"$watermelon: #FF4168;\n"
"$light-30: rgba(152, 166, 179, .3);\n"
"$light-70: rgba(152, 166, 179, .7);\n"
"$cerulean: #007DC0;\n"
"$wheat: #FFD37E;\n"
"$off-white-two: #FFF6E1;\n"
"$pale-peach-two: #FFDEAD;\n"
"$ice-blue: #ECF9FF;\n"
"$pale-sky-blue: #B7E7FF;\n"
"$slate: #516272;\n"
"$bluey-grey: #97A6B2;\n"
"$bluey-grey-two: #98A7B3;\n"
"$bluey-grey-three: #A7B6C2;\n"
"$slate-three: #405064;\n"
"$slate-two: #404F5F;\n"
"$silver-four: #DEE1E4;\n"
"$silver-five: #D9DCDF;\n"
"$coral-pink: #FF5771;\n"
"$silver-six: #C0C9D0;\n"
"$sky-blue: #5CC7FF;\n\n"
":export {\n"
" dark: $dark;\n"
" dark10: $dark-10;\n"
" dark20: $dark-20;\n"
"}\n\n"
"// not registered in zeplin\n"
"$warm-dark: #404F5F; // #435262\n"
"$warm-dark-40: rgba(64, 79, 95, .4); // rgba(64, 80, 101, .4)\n"
"$soft-sky: #8FD8FF;\n"
"$charcoal-grey-two: #2F343A;\n"
"$azure-three: #00C3FF;\n"
"$deep-green: #00A02E;\n"
"$sun-yellow: #F5E11F;\n"
"$cadet-blue: #52689D;\n"
"$greenblue: #00D175;\n"
"$greenblue-two: #00B07F;\n"
"$light-sky-blue: #CCF3FF;\n"
"$event-header: #EDEFF0;\n\n"
"// react table\n"
"$tr-group-border: rgba(0, 0, 0, .05);\n\n"
"// shop AB funnel page\n"
"$resource-a: #7ab8fc;\n"
"$resource-b: #86919f;\n\n"
":export {\n"
" resourceA: $resource-a;\n"
" resourceB: $resource-b;\n"
"}\n")
matches = re.finditer(regex, test_str, re.MULTILINE)
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