Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RE: AWK
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
wtnabe
February 15, 2014
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RE: AWK
Introduction of Regular Expression and AWK on my own
wtnabe
February 15, 2014
More Decks by wtnabe
See All by wtnabe
新しいフロントプロセスとドキュメントフォーマットを考えてみた
wtnabe
0
51
Rubyでもモノリポしたい - 調査、おさわり編 -
wtnabe
0
80
Ruby de Railway Oriented Programming
wtnabe
0
130
Bindanのススメ
wtnabe
0
76
そのオブジェクト、何を保証してくれますか? - GuideRailのススメ -
wtnabe
0
84
Effective Jekyll
wtnabe
0
110
5 min Jekyll/Liquid Plugin cooking
wtnabe
0
75
Ruby de Wasm
wtnabe
0
110
Cloud Native Buildpacksって結局どうなの?
wtnabe
0
93
Other Decks in Programming
See All in Programming
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
ジョジョの世界をXRで再現する
mofurune
0
160
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
2
540
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
110
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
270
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
APNsからLive Activityを開始する話
yumnumm
0
170
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
270
R8 の設定見直しでアプリサイズ削減
andpad
0
220
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
500
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
Six Lessons from altMBA
skipperchong
29
4.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Un-Boring Meetings
codingconduct
0
460
Transcript
RE: AWK @wtnabe Kanazawa.rb meetup #18 2014-02-15 (Sat) at IT
Plaza MUSASHI
Abstract
Regular Expression Basics AWK Basics
Regular Expression Basics
Difficulties of RE Many different implementations Complex Character Sequences
Rough Classification POSIX ( Basic / Extended ) PCRE (Perl
Compatible Regular Expression) PHP, Apache, GNU Grep, ... GNU ( Basic / Extended ) and more
Ignore Minor tool's original expressions What does grep in your
tools mean ?
Basic Syntax Literal Character Meta Character / Escape Sequence Character
List / Character Class Grouping and Back reference
Elementary Operators . * + ? | () grouping and
back reference
Elementary Operators ^ $ ( \A \z ) \r \n
\s \xXX escape sequence [] [^] character list
RE Literal and Language Syntax Such as escape sequence CONFLICT
with parent language Some Languages have RE Literal AWK, Perl, Ruby, JavaScript, ...
Examples /^[0-9]+(-[0-9]+)+$/ /\s[Kk]anazawa\.rb\s/ %r{\bhttps?://.*\b}
Keep away Too Match /[0-9-]+/ Complex one-shot match q{[^"'<>]*(? :"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?
:>|(?=<)|$(?!\n))}; #'}}}} cf. Perlメモ
AWK
Name from famous Human Names Aho Weinberger Kernighan
Filter-oriented Programming Language $ awk 'script' srcfile $ cat srcfile
| awk 'script' > destfile $ awk -f script srcfile
Basic Syntax C-like / Shell-like ( semicolon less ) Patterns
and Actions No need to write about stdin and split
Patterns and Actions pattern { action } pattern { action
}
BEGIN and END rule BEGIN { ... } END {
... }
Example Count a number of gems depending on from Gemfile.lock
Gemfile.lock GEM remote: https://rubygems.org/ specs: blankslate (2.1.2.4) ... PLATFORMS ruby
DEPENDENCIES ...
BEGIN { counting = 0 } /^$/ { counting =
0 } counting == 1 && !/:/ { print $1 } /^GEM$/ { counting = 1 }
$ awk -f script.awk Gemfile.lock | \ sort | uniq
| wc -l
Same as NF == 2 && $2 ~ /\(.*\)/ {print
$1}
Notes http://www.regular-expressions.info/ 正規表現メモ The GNU Awk User's Guide The GAWK
Manual - Table of Contents