SlideServe
Menu
Préférences
© SlideServe · v2026

Mastering Regular Expressions in Python for NLP

kellybradley avatar
6 diapositives · 183 Views · Jan 06, 2020

Learn how to harness the power of regular expressions for advanced string manipulation in Python for Natural Language Processing. Explore search, replace, and split operations with syntax examples.

Mastering Regular Expressions in Python for NLP - slide 1
01 / 6Mastering Regular Expressions in Python for NLP
1 / 17

Télécharger la présentation

Mastering Regular Expressions in Python for NLP
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Python for NLP Regular Expressions CS1573: AI Application Development, Spring 2003 (modified from Steven Bird’s notes)

  2. Regular Expressions • Regular expressions are a powerful string manipulation tool. • Use regular expressions to: • Search a string (search and match) • Replace parts of a string (sub) • Break stings into smaller pieces (split)

  3. Regular Expression Python Syntax • Most characters match themselves. For example, the regular expression “test” matches the string ‘test’, and only that string. • [x] matches any one of a list of characters. For example, “[abc]” matches ‘a’,‘b’,or ‘c’. • [^x} matches any one character that is not included in x. For example, “[^abc]” matches any single character except‘a’,’b’,or ‘c’. • “.” matches any single character.

  4. Regular Expressions Syntax (cont’d) • Parentheses can be used for grouping. For example, “(abc)+” matches ’abc’, ‘abcabc’, ‘abcabcabc’, etc. • x|y matches x or y. For example, “this|that” matches ‘this’ and ‘that’, but not ‘thisthat’.

  5. Regular Expression Syntax (cont’d) • x* matches zero or more x’s. For example, “a*” matches ’’,’a’,’aa’,etc. • x+ matches one or more x’s. For example, “a+” matches ’a’,’aa’,’aaa’, etc. • x? matches zero or one x’s. For example, “a?” matches ’’ or ’a’ . • x{m, n} matches i x‘s, where m<i< n. For example, “a{2,3}” matches ’aa’ or ’aaa’

  6. Regular Expression Syntax (cont’d) • “\d” matches any digit; “\D” matches any non-digit. • “\s” matches any whitespace character; “\S” matches any non-whitespace character • “\w” matches any alphanumeric character; “\W” matches any non-alphanumeric character. • “^” matches the beginning of the string; “$” matches the end of the string. • “\b” matches a word boundary; “\B” matches position that is not a word boundary.