0

I am supposed to use the command line argument to save content to keywords or (and here is my issue; delete keywords)

Hey I already researched similar questions. However, I do not see why it does not work out in my program. Every time I use python mcb.py delete a. It still comes up. I cannot delete it. Hope you can help me out on this one

#! /usr/bin/env python3

import sys, pyperclip, shelve

mcbShelf = shelve.open('mcb')

if len(sys.argv) == 3 and sys.argv[1].lower() == 'save':
    mcbShelf[sys.argv[2]] = pyperclip.paste()
elif len(sys.argv) == 2:
    if sys.argv[1].lower() == 'list':
        pyperclip.copy(str(list(mcbShelf.keys())))
    elif sys.argv[1] in mcbShelf:
        pyperclip.copy(mcbShelf[sys.argv[1]])
    elif len(sys.argv)==3 and sys.argv[1].lower() == 'delete':
        #del mcbShelf[sys.argv[2]]
        mcbShelf.pop(sys.argv[2])
        #mcbShelf.clear()
#mcbShelf.pop(sys.argv[2])
mcbShelf.close()
  • Look (again?) into character classes, `[Telefon:./]` does not what you think it does. Also, you surely meant `mo = telefonReg.findall(some_string_from_tu_berlin_here)` (without the quotes, that is). – Jan Aug 25 '20 at 19:34
  • In addition to regex issues, you're searching the string 'tu_berlin', if you want to search the data you download, you either need to load it from the text file, or keep a copy in a variable to search. – Anon Coward Aug 25 '20 at 19:46

1 Answers1

0

I think you're looking for (Telefon:.\/\s)?(\+)\d{2}\s\d{2}\s\d{3}\s\d{5}. This moves the Telefon to a separate group (which matches the whole group literally) instead of a character set (which matches any character in the set). The + also needed to be escaped.

melbok
  • 95
  • 7