# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^I await your input\.(?=\d|\-)|^(?:I await your input\.(?:x|\/|\*|\+|\.))|^0+(?=0|0.|[1-9])|(?<=\.\d+)\.$|^(?:x|\/|\*|\+|\.)|(?<=(?:x|\/|\*|\-|\+))0(?=\d+)|(?<=\.)\-$|(?<=^\-)(?:x|\*|\/|\-|\+|\.)|(?<=\.\d+)(x|\*|\/|\-|\+)?\."
test_str = ("|(?<=(?:x|\\/|\\*|\\-|\\+|\\.))(?:x|\\/|\\*|\\+|\\.)\n"
"/When ready, just start over from the original working regex.\n"
"|(?<=\\d+)(x|\\*|\\/|\\-|\\+)(?=x|\\*|\\/|\\-|\\+)\n"
"|(?<=x|\\*|\\/|\\-|\\+|\\.)\\.\n"
"|\\.(?=x|\\*|\\/|\\-|\\+|\\.)|(?<=\\d+\\.\\d+(?:x|\\*|\\/|\\-|\\+))\\.|(?<=\\d+\\.\\d+)\\.\n"
"Seems like I don't need this one: |\\-(?=-)\n"
"40.0.\n"
"5.6+.\n"
"7.3.\n"
"2222-\n"
"2222--\n"
"2222.-\n"
"0.00002/\n"
"111.222*x\n"
"3838.3\n"
"0.0000x.\n"
"1+2.333.x\n"
"-/1\n"
"-/1/-\n"
"1.1/+\n"
"0.2/*\n"
"333/x\n"
"4444/-\n"
"888-\n"
"0x/\n"
"0..+\n"
"0xx\n"
"3x.\n"
"3.xx\n"
"0.1.\n"
"++++++++++++++++++++++++++++++++++\n"
"(?<=\\d+(?:x|\\/|\\*|\\-|\\+|\\.))(?:x|\\/|\\*|\\-|\\+|\\.)\n"
"(?<=\\.\\d+(?:x|\\/|\\*|\\-|\\+|\\.))(?:x|\\/|\\*|\\-|\\+|\\.)\n"
"(?<=\\d+(?:x|\\/|\\*|\\-|\\+|\\.))(?:x|\\/|\\*|\\-|\\+|\\.)\n"
"(?<=\\d+)(?:x|\\/|\\*|\\-|\\+|\\.)(?=x|\\/|\\*|\\-|\\+|\\.) // This selects any math symbol directly after a math symbol such as 111.222*x (x will be selected)\n"
"?:non-capturing group\n"
"I await your input.4\n"
"I await your input.+\n"
"abcdefghijklmnopqrstuvwxyz\n"
"....\n"
"0000000\n"
"000000033300\n"
"00003304\n"
"0000004\n"
"000000.\n"
"2.5+88889.4756x8.8/0.125+04.5\n"
"2.5+88889.4756x8.8/0.125+0.45\n"
"2.5+88889.4756x8.8/0.125+0\n"
"2.4+2.00003\n"
"2.4+04\n"
"0x9-95.8/00\n"
"/*\n"
"+-+\n"
"000000004\n"
"6.6.4444.4.4.5555.588885.5.\n"
"6.6.4444.4.4.5555.55.5343.\n"
"4+5\n"
"88889993.4884.\n"
"4.\n"
"8888.8.4\n"
"8.8.4.8\n"
"4.56850.000000.0.100.324000+8.343.333.4400000.00000\n"
"0.13453.383883...+388338.383838+3.4/833.3x8*4333-8-+++**3*3/*3\n"
"0000.1\n"
"+\n"
"-\n"
".\n"
"*\n"
"/\n"
"x0000000\n"
"000000004\n"
"0.1334343.\n"
"0123456789\n"
"000001234\n"
"0000.\n"
"_+-*/|\\/*\n"
"@#!#$\n"
"^*()\n"
".000\n"
"copied and saved regex:\n"
"|(?<=.[\\d+])\\.\n"
"_______________________________\n"
"(?<=\\d|\\d)\\.$\n"
"// sort of works: \\.\\d+\\.$(?!\\d+\\.) it takes of the .allnumbesanddecimal from here\n"
"(?<=\\.)\\d+\\.$\n"
"(?<=\\.\\d+)\\.$\n"
"(\\.\\d+)$\n"
"(?<=[\\d]\\.[\\d])\\.\n"
"Negate these: \n"
"[^0\\.1]")
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