DEV Community

Durga Pokharel
Durga Pokharel

Posted on • Edited on

4

Day 13 of 100DaysOfCode: Regular Expressions

This is my 13 day of #100daysofcode. Today I learned more about CSS properties like create a gradual CSS linear gradient, use a linear gradient to create a striped element, create texture by adding a subtle pattern as a background image, use the CSS transform scale property to change the size of an image, use the CSS transform scale property to scale an element on hover etc from freecodecamp.
Also I learned something about web access to python from Coursera.

Below is my code of this day

Spam Confidence

Regular expression referred to as "regex" or "regexp", provides a concise and flexible means for matching strips of text. My code is start with importing regular expression as re as given below.

import re
Enter fullscreen mode Exit fullscreen mode

After that we open the file as hand and I build the list to put the number. I started the loop after that I strip line. We going to look findall . Look for the line start with X quit it will be stop in the blank. Then it will start extracting 0 through 9 for floating number bracket one or more time and the we end extracting. There is exactly one extraction. If there is no extraction then this code run empty extraction. This stuff is the list of the matches. If there will be more than one that type of floating number go through below and choose the maximum one.

hand = open("mbox-short.txt")
numlist = list()
for line in hand:
    line = line.rstrip()
    stuff = re.findall('^X-DSPAM-Confidence: ([0-9.]+)',line)
    if len(stuff) != 1 : continue
    num = float(stuff[0])
    numlist.append(num)
print('Maximum:',max(numlist))

Enter fullscreen mode Exit fullscreen mode

Day 13 of #100dysofcode and #Python
* More about CSS properties including create a gradual css linear gradient , use a css linear gradient to create a striped element, create texture by adding a subtle pattern as a background image..
* More about python to access web data pic.twitter.com/Mg2vXHWnoa

— Durga Pokharel (@mathdurga) January 6, 2021

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay