Giter Club home page Giter Club logo

regular-expressions's Introduction

Regular-Expressions

Match method

re.match(pattern,text) -> searches for the pattern only in the beginning of the string.

This file, covers the following topcis -

  • Difference between raw string and python string.
  • match method in re library
  • how to write unit test

Search, findall,finditer and groups

re.search(pattern,text) -> returns the first match in the text. re.findall(pattern,text) -> returns a list of all the matches. re.findieter(pattern,text) -> returns an iterator

This file,covers the following topic -

  • search method in re, and how its different from match
  • findall mehod
  • finditer, and how it covers up the possible disadvantage of findall
  • groups, and how we can name the groups.

Find and replace, Split

re.sub(pattern, replacement pattern / function, text) -> returns the text where the string matching the pattern is replaced by a string given by the replacement pattern / function

This file covers the following topic-

  • using re.sub with a pattern
  • using re.sub with a user defined function
  • re.split

Single character patterns

This file covers the following topic -

  • searching for a single character, and making the search case insensitive.
  • Using range of characters to search, eg, [a-z]
  • Using wildcard .(dot) to find all characters also, how can we search if we want to search a dot.
  • Finding newlines, using hexadeciaml code and unicode.

Anchors

This file covers the following topic -

  • searching for a given word (using word boundary)
  • searching for a word at beginning of a string ( by using '^' )
  • enabling multiline mode and searching for a word at the beginning of all lines.
  • searching for a word at the end of a string (by using '$' )
  • enabling multiline mode and searching for a word at the end of all lines

Character classes

This file covers the following topic -

  • searching for word digits using \d character class
  • searching digits in other scripts than english
  • using negation \D
  • seaching for alpa numeric characters using \w
  • using \w in devnagari script
  • using the negation of \w, which is \W

Quantifiers

This file covers the following topics -

  • Searching words with custom matches like -
    • aplhabet followed by a digit
    • alphabet followed by zero or more digit
    • alphabet followrd by one or more digit
    • two alphabets followed by one or more digits

regular-expressions's People

Contributors

hardikkamboj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.