From b18a372b4b52b0e01f9e9ed308a8f20abb06cc94 Mon Sep 17 00:00:00 2001 From: yasindindar <77322841+yasindindar@users.noreply.github.com> Date: Wed, 24 Feb 2021 10:23:09 +0100 Subject: [PATCH] Add files via upload --- 1- Identity Number.py | 9 +++++++++ 2- Find eight letter long words.py | 26 ++++++++++++++++++++++++++ 3- Listing by email addresses.py | 11 +++++++++++ 3 files changed, 46 insertions(+) create mode 100644 1- Identity Number.py create mode 100644 2- Find eight letter long words.py create mode 100644 3- Listing by email addresses.py diff --git a/1- Identity Number.py b/1- Identity Number.py new file mode 100644 index 0000000..fe2a8c8 --- /dev/null +++ b/1- Identity Number.py @@ -0,0 +1,9 @@ +import re + + +def identify_id(str): + return re.findall("\w{2}\d\w{2}\d{2}\w\d", str)[0] + + +print("Identity Number:", identify_id('AEGTV5VZ4PF94B6YH678')) +print("Identity Number:", identify_id('AABZA1111AEGTV5YH678MK4FM53B6')) diff --git a/2- Find eight letter long words.py b/2- Find eight letter long words.py new file mode 100644 index 0000000..b1946ee --- /dev/null +++ b/2- Find eight letter long words.py @@ -0,0 +1,26 @@ +import re + +text1 = '''Without, the night was cold and wet, but in the small parlour of Laburnum villa the blinds were drawn and +the fire burned brightly. Father and son were at chess; the former, who possessed ideas about the game involving +radical chances, putting his king into such sharp and unnecessary perils that it even provoked comment from the +white-haired old lady knitting placidly by the fire. "Hark at the wind," said Mr. White, "who, having seen a fatal +mistake after it was too late, was amiably desirous of preventing his son from seeing it. I'm listening," said the +latter grimly surveying the board as he stretched out his hand. "Check." I should hardly think that he's come +tonight," said his father, with his hand poised over the board. "Mate," replied the son. "That's the worst of living +so far out," balled Mr. White with sudden and unlooked-for violence; "Of all the beastly, slushy, out of the way +places to live in, this is the worst. Path's a bog, and the road's a torrent. I don't know what people are thinking +about. I suppose because only two houses in the road are let, they think it doesn't matter." ''' + + +# 8 karakterden uzun olan kelimelerin elenmesi için regeximizin +# başına ve sonuna karakter olmayan (\W) eleman arıyoruz dedik +pattern = "\W\w{8}\W" +re.search(pattern, text1) +for found in re.findall(pattern, text1): + + if found[0] != "\w": + # eger kelimenin başındaki ve sonundaki eleman harf değilse kırpıyoruz. + found = found[1:9] + if found[-1] != "\w": + found = found[0:9] + print(found) diff --git a/3- Listing by email addresses.py b/3- Listing by email addresses.py new file mode 100644 index 0000000..0a792b0 --- /dev/null +++ b/3- Listing by email addresses.py @@ -0,0 +1,11 @@ +import re + + +def user_name(text_2): + # parantezle sadece @'den önceki kısmı almış oluyor + return re.findall("(\w+)@", text_2) + + +text_2 = "The advencements in biomarine studies franky@google.com with the investments necessary and " \ + "Davos sinatra123@yahoo.com. Then New Yorker article on wind farms... " +print(*user_name(text_2), sep='\n')