Skip to main content

Command Palette

Search for a command to run...

Regular Expressions in Natural Language Processing

Regular Expressions is very popular among programmers and can be applied in many programming languages like Java, JS, php, C++, etc.

Updated
•1 min read•View as Markdown
Regular Expressions in Natural Language Processing
N

Computer Science enthusiast || Blogger writing|| Digital Marketing|| Data Science || R language || Microsoft || DBMS|| Python||

Regular Expressions in Natural Language Processing

Regular Expressions is very popular among programmers and can be applied in many programming languages like Java, JS, php, C++, etc.

Regular Expressions are used in various tasks such as data pre-processing, rule-based information mining systems, pattern matching, text feature engineering, web scraping, data extraction, etc.

Python Built-in Module for Regular Expressions

Python has a built-in module to work with regular expressions called “re”. Some common methods from this module are- • re.match() • re.search() • re.findall()

Let us look at each method with the help of an example-

  1. re.match(pattern, string) The re. match function returns a match object on success and none on failure.
  1. re.search(pattern, string) Matches the first occurrence of a pattern in the entire string(and not just at the beginning).

  2. re.findall(pattern, string) It will return all the occurrences of the pattern from the string. I would recommend you to use re.findall() always, it can work like both re.search() and re.match().

More from this blog

Pushpraj blog

12 posts

Python | Mentor | Python at Scale | Technical Skills (Microsoft Office | Data Structure | Database Management | SEO | Windows XP | Numpy, Pandas, Python, R prog