. .
Regular Expressions for Linguists: A Life Skill
Michael Yoshitaka Erlewine
mitcho@mitcho.com
Hackl Lab Turkshop March 2013
. .
Regular Expressions for Linguists: A Life Skill . Michael - - PowerPoint PPT Presentation
. Regular Expressions for Linguists: A Life Skill . Michael Yoshitaka Erlewine mitcho@mitcho.com Hackl Lab Turkshop March 2013 . . Regular Expressions What are regular expressions? Regular Expressions (aka regex es or regexp s) are a
mitcho@mitcho.com
. .
. . 2
. .
. .
. .
. .
. . 1 Open the file lookingglass.txt in your editor and count the
. .
. . 1 Does the text have any tabs? . . 2 Search for Alice\n. What did you find? . . 3 Find five-letter words with \s\w\w\w\w\w\s. What problem(s)
. . 4 This file annoyingly has line breaks in the middle of sentences. Find
. .
. . 1 Find sequences of three vowels in a row with
. . 2 Find sequences of three capital letters in a letter
. .
. . 1 Search for \bcat\b. What did you find? . . 2 Search for \bcat\w. What did you find? . . 3 Find some words that start with “q”. . . 4 How ofuen is “Alice” at the beginning of a line? At the end of a line? . . 5 Does ^through pick out the same things as \nthrough?
. .
. . 1 Search for (cat|dog)s. What did you find?
. .
. . 1 Find all words that end in -ing. Make sure you select the entire
. . 2 Find all words that end in -ing or the plural -ings. . . 3 How many exactly-ten-letter words are there? . . 4 How many matches of \b[\w’]{10}\b are there? What is this? . . 5 What’s the longest word in the text? . . 6 What’s the longest word in the text which can be typed using only the
. . 7 Find the line that both the “Red Queen” and “Red King” are in.
. .12
. .
. . 1 Search for \b(\w+)␣\1\b. What did you find? . . 2 Search for \b(\w)\w*␣\1\w*\b. What does this find? . . 3 Replace all the line breaks inside paragraphs, but keep the paragraph
. .
. . 1 Take each sentence and replace “made V” with the appropriate
. . 2 Take each line and turn it into two lines: one as is and the other with
. . 1 Take each sentence and split it into two sentences, using the options
. .