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
Introduction to Regular Expression
Search
N@N
September 21, 2013
Technology
0
330
Introduction to Regular Expression
姫路IT系勉強会 Vol.20で発表した内容に加筆・修正を加えたものです.
N@N
September 21, 2013
Tweet
Share
More Decks by N@N
See All by N@N
introduction to modern numerical analysis
spark6251
0
140
Finite Automaton equivalents to Regular Expression
spark6251
0
110
Programmer and English
spark6251
0
110
Let's go to the study session
spark6251
0
93
Quantum Computation
spark6251
0
260
Introduction to use Grunt
spark6251
0
79
Introduction to SCSS+COMPASS
spark6251
0
260
Introduction to Psychology
spark6251
1
250
Introduction to HTML5
spark6251
0
260
Other Decks in Technology
See All in Technology
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
2
120
AWS re:Invent 2024 ふりかえり勉強会
yhana
0
490
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
270
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
290
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
340
いまからでも遅くないコンテナ座学
nomu
0
130
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
170
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
ハイテク休憩
sat
PRO
2
180
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
120
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
210
Opcodeを読んでいたら何故かphp-srcを読んでいた話
murashotaro
0
320
Featured
See All Featured
Thoughts on Productivity
jonyablonski
68
4.4k
How STYLIGHT went responsive
nonsquared
96
5.2k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Optimizing for Happiness
mojombo
376
70k
4 Signs Your Business is Dying
shpigford
182
21k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Documentation Writing (for coders)
carmenintech
67
4.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Mobile First: as difficult as doing things right
swwweet
222
9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Visualization
eitanlees
146
15k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Transcript
None
• • • • •
• • • • •
• •
• • • •
• . • • • •
• • •
• • • •
• • • • $ egrep [option] 'regex' file1 file2...
• $ egrep '[0-9]{3}-?[0-9]{4}' file01 • 1000 14 • validator
• Number::ZipCode::JP
• • • • •
• ^ • • '^cat' • •
• $ • • 'cat$' • •
• '^$' • • • '^cat$' • •
• '^' • • • '$' • •
• [...] • • 'gr[ae]y' • • •
• • '[0123456789]' = '[0-9]' • '[ABCDE...Z]' = '[A-Z]' •
'[abcde...z]' = '[a-z]' • '[012...9ABCDEFabcdef]' = '[0-9A-Fa-f]' • • [Ss]mith' blacksmith
• [^...] • • • '[^0-9]' • •
• $ egrep 'A[^B]' file01 • • •
• . • • 'A.B' •
• | • • 'gr[ae]y' = 'gr(a|e)y' = 'gray|grey' •
'gra|ey' gra ey • '[a|e]' a | e
• • • $ egrep -i 'from|to' file = $
egrep '[Ff][Rr][Oo][Mm]|[Tt][Oo]' file
• ¥<string¥> • egrep • the quick brown_ fox's $190.3?
$!?. •
• ? • • • • 'colou?r' • • '1st|1'
= '1(st)?'
• + • • * • • 'A+' = 'AA*'
• 'AA*' ≠ '(AA)*'
• ¥char • • '¥.' •
^ $ . [ABC] [^ABC] [A-Z] [^A-Z] c1|c2
+ * ? {n} {n,} {,m} {n,m} () ¥char
• • • • •
•
• •
• m • m/regex/mods • • s/regex/replacement/mods • • value
=~ /regex/mods • •
• /i • /x • /g
• • • ¥<(.*?)>.*?</¥1>¥ • <a>sdad</a> <list>dfasj</list>
• if($str =~ /(.*)?/) { print $1; # () }
$ perl [option] '[perlScript]' file01 • -e • -n 1
• -p • -l • -i
$ perl -i'*.back' -e '[perlScript]' file
$ find . -type f -print0 | xargs -0 sed
-i -e 's/foo/bar/g' $ git grep -l 'foo' | xargs -0 sed -i -e 's/foo/bar/g' $ git ls-files -z | xargs -0 sed -i -e 's/foo/bar/g'
• • • •
•
• • • •
• • • •
• • • •
• • • •
• • • • •
None
• • • •
• • • • • • • •
• • • • • • •
• • • • • • •
• • • •
None
• • • •
• • • • •
None
• • •
None
• •
None
• •
• •
• •
None
• •
• •
• • • • • • •
• • • •
• 'nfa|nfa not' • •
• 'X(.+)+X' • • • •
• • 'a.*b'
• • '^.*' •
• • 'to(nite|knight|night)' • •
• • • 'to(nite|knight|night)'
• • • • • •
• • • •
• • • •
• •
• • • • • •
None