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
350
0
Share
Introduction to Regular Expression
姫路IT系勉強会 Vol.20で発表した内容に加筆・修正を加えたものです.
N@N
September 21, 2013
More Decks by N@N
See All by N@N
introduction to modern numerical analysis
spark6251
0
190
Finite Automaton equivalents to Regular Expression
spark6251
0
140
Programmer and English
spark6251
0
120
Let's go to the study session
spark6251
0
110
Quantum Computation
spark6251
0
270
Introduction to use Grunt
spark6251
0
97
Introduction to SCSS+COMPASS
spark6251
0
300
Introduction to Psychology
spark6251
1
280
Introduction to HTML5
spark6251
0
310
Other Decks in Technology
See All in Technology
OpenClawでPM業務を自動化
knishioka
2
360
Physical AI on AWS リファレンスアーキテクチャ / Physical AI on AWS Reference Architecture
aws_shota
1
280
FlutterでPiP再生を実装した話
s9a17
0
240
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
77k
AI時代のシステム開発者の仕事_20260328
sengtor
0
320
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
5
1.3k
Bref でサービスを運用している話
sgash708
0
220
自分をひらくと次のチャレンジの敷居が下がる
sudoakiy
5
1.6k
第26回FA設備技術勉強会 - Claude/Claude_codeでデータ分析 -
happysamurai294
0
320
タスク管理も1on1も、もう「管理」じゃない - KiroとBedrock AgentCoreで変わった“判断の仕事”
yusukeshimizu
0
160
最大のアウトプット術は問題を作ること
ryoaccount
0
260
VSCode中心だった自分がターミナル沼に入門した話
sanogemaru
0
890
Featured
See All Featured
Bash Introduction
62gerente
615
210k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How STYLIGHT went responsive
nonsquared
100
6k
AI: The stuff that nobody shows you
jnunemaker
PRO
4
500
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
230
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
53k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
340
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
160
Producing Creativity
orderedlist
PRO
348
40k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
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