Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RE: AWK
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
wtnabe
February 15, 2014
Programming
250
0
Share
RE: AWK
Introduction of Regular Expression and AWK on my own
wtnabe
February 15, 2014
More Decks by wtnabe
See All by wtnabe
Rubyでもモノリポしたい - 調査、おわわり編 -
wtnabe
0
41
Ruby de Railway Oriented Programming
wtnabe
0
84
Bindanのススメ
wtnabe
0
52
そのオブジェクト、何を保証してくれますか? - GuideRailのススメ -
wtnabe
0
70
Effective Jekyll
wtnabe
0
93
5 min Jekyll/Liquid Plugin cooking
wtnabe
0
55
Ruby de Wasm
wtnabe
0
85
Cloud Native Buildpacksって結局どうなの?
wtnabe
0
69
Decoupled System with Turbo Frame
wtnabe
1
170
Other Decks in Programming
See All in Programming
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
490
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
110
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
iOS機能開発のAI環境と起きた変化
ryunakayama
0
190
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
990
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
450
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
170
AIエージェントで業務改善してみた
taku271
0
540
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
180
AIを導入する前にやるべきこと
negima
2
120
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
3k
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
1.1k
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
170
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
Being A Developer After 40
akosma
91
590k
Designing for Performance
lara
611
70k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
180
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
130
The Invisible Side of Design
smashingmag
303
52k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
340
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