SlideShare a Scribd company logo
1 of 36
Download to read offline
@dankogai
my$talk=qr{((?:ir)?reg(?:ular )?
exp(?:ressions?)?)}i;
Table of Contents
• regexp? what is it?


• $supported_by ~~ @most_major_languages;


• but how (much)??


• Unicode support?


• assertions?


• modifiers?


• Irregular expressions


• qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))}


• use CPAN;


• Regexp::Assemble;


• Regexp::Common;


• (ir)?regular questions (?:from|by) the audience
regexp? what is it?
Mathematically speaking[*]
• The empty language Ø is a regular language.

• For each a ∈ Σ (a belongs to Σ), the singleton language {a} is a regular
language.

• If A is a regular language, A* (Kleene star) is a regular language. Due to this,
the empty string language {ε} is also regular.

• If A and B are regular languages, then A ∪ B (union) and A • B (concatenation)
are regular languages.

• No other languages over Σ are regular.
regexp? what is it?
In our language
• 0 or more of… (quantifier)


• '' # empty string


• 'string' # any string


• '(?:string|文字列)' # any alteration of strings


• That's it!


• ? # {0,}


• + # {1,}


• [0-9] # (?:0|1|2|3|4|5|6|7|8|9)
regexp? what is it?
((?:ir)?reg(?:ular )?exp(?:ressions?)?)
Visualized by: regexper.com
regexp? what is it?
(?:[x00-x7F]|[xC2-xDF][x80-xBF]|xE0[xA0-xBF][x80-xBF]|[xE1-xECxEExEF][x80-xBF]{2}|xED[x80-x9F][x80-xBF]|
xF0[x90-xBF][x80-xBF]{2}|[xF1-xF3][x80-xBF]{3}|xF4[x80-x8F][x80-xBF]{2})
Exerpt from: https://www.w3.org/International/questions/qa-forms-utf-8
Visualized by: regexper.com
regexp? what is it?
(?:[+-]?)(?:0x[0-9a-fA-F]+(?:.[0-9a-fA-F]+)?(?:[pP][+-]?[0-9]+)|(?:[1-9][0-9]*)(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0(?:.0+|(?:.0+)?(?:[eE]
[+-]?[0-9]+))|(?:[Nn]a[Nn]|[Ii]nf(?:inity)?))
Exerpt from: https://github.com/dankogai/js-sion/blob/main/sion.ts
Visualized by: regexper.com
Irregular expressions
/^(11+?)1+$/ # is this a regular expression?
$ seq 2 100 | perl -nlE 'say $_ if (1x$_) !~ /^(11+?)1+$/'
Irregular expressions
/^(11+?)1+$/ # is this a regular expression?
$ seq 2 100 | perl -nlE 'say $_ if (1x$_) !~ /^(11+?)1+$/'
2
3
5
7
…
79
83
89
97
Irregular expressions
/^(11+?)1+$/ # is NOT EXACTLY a regular expression!
• The problem is 1


• It is the result of the preceding capture


• In other words, this expression is self-modifying.


• So it is not mathematically a regular expression


• Regexp ≠ Regular Expression


• Regexp ⊆ Regular Expression
Irregular expressions
qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))}
• Q: Can a regular expression match nested parentheses?


• A: No. But some regex engines allow you to do that.
Irregular expressions
qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))}
my $re = qr{(
[A-Za-z_]w*s*
(
(
(
(?:
(?>[^()]+)
|
(?2)
)*
)
)
)
)
}x;
Irregular expressions
qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))}
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':all';
my $re = qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))};
my $str = '$result = a(b(c),d(e,f(g,g,g)))';
$str =~ $re;
say $1;
say $2;
say $3;
Unicode Support
What is a character?
• String is /.*/ but . =


• [x00-xff] # legacy world of bytes


• [u0000-uFFFF] # prematurely modern


• [u{0000}-u{10FFFF}] # correctly modern
Unicode Support
What is a character?
• String is /.*/ but . =


• [x00-xff] # Perl < 5.7


• [u0000-uFFFF] # Java(Script)?, Python2, …


• [u{0000}-u{10FFFF}] # Perl, Ruby, Python3, …
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🦏🐪🐘🐍💎⚙" =~ /(.)/g); say Dumper([@m])'
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🦏🐪🐘🐍💎⚙" =~ /(.)/g); say Dumper([@m])'
$VAR1 = [
"x{1f98f}",
"x{1f42a}",
"x{1f418}",
"x{1f40d}",
"x{1f48e}",
"x{2699}"
];
Unicode Support?
What will the following say?
$ node -e 
'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/g))'
Unicode Support?
What will the following say?
$ node -e 
'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/g))'
[
'', '', '', '',
'', '', '', '',
'', '', '⚙'
]
Unicode Support?
What will the following say?
$ node -e 
'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/ug))'
[ '🦏', '🐪', '🐘', '🐍', '💎', '⚙' ]
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])'
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])'
$VAR1 = [
"x{1f1ef}",
"x{1f1f5}",
"x{1f1fa}",
"x{1f1e6}"
];
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])'
$VAR1 = [
"x{1f1ef}", # REGIONAL INDICATOR SYMBOL LETTER J
"x{1f1f5}", # REGIONAL INDICATOR SYMBOL LETTER P
"x{1f1fa}", # REGIONAL INDICATOR SYMBOL LETTER U
"x{1f1e6}" # REGIONAL INDICATOR SYMBOL LETTER A
];
Unicode Support?
What will the following say?
$ perl -Mutf8 -MData::Dumper -E 
'my@m=("🇯🇵🇺🇦" =~ /(X)/g); say Dumper([@m])'
$VAR1 = [
"x{1f1ef}x{1f1f5}",
"x{1f1fa}x{1f1e6}"
];
Unicode Support?
What will the following say?
$ node -e 
'console.log("🇯🇵🇺🇦".match(/(.)/ug))'
Unicode Support?
What will the following say?
$ node -e 
'console.log("🇯🇵🇺🇦".match(/(.)/ug))'
[ '🇯', '🇵', '🇺', '🇦' ]
Unicode Support?
What will the following say?
$ node -e 
'console.log("🇯🇵🇺🇦".match(/(X)/ug))'
🙅 [ '🇯🇵','🇺🇦' ]
🙆 SyntaxError: Invalid regular expression: /(X)/: Invalid escape
at [eval]:1:24
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:75:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:74:60)
at node:internal/main/eval_string:27:3
🤦
Unicode Support?
Grapheme Cluster
• Defined in:


• https://unicode.org/reports/tr29/


• X is supported by:


• 🐘 PHP


• 🐪 Perl


• 💎 Ruby


• Not yet supported by:


• 🦏 JavaScript


• 🐍 Python
use CPAN
Regexp::Common
$ perl -MRegexp::Common -E 'say $RE{net}{IPv6}'
use CPAN
Regexp::Common
$perl -MRegexp::Common -E 'say $RE{net}{IPv6}'
(?:(?|(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-
fA-F]{1,4})|(?::(?:)(?:):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}))|(?::(?:)(?:)(?:):
(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}))|(?::(?:)(?:)(?:)(?:):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]
{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}))|(?::(?:)(?:)(?:)(?:)(?:):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}))|(?::(?:)(?:)(?:)(?:)(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):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:):
(?:[0-9a-fA-F]{1,4}))|(?:(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:)(?:):)|(?:(?:[0-9a-fA-F]
{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:):)))
use CPAN
Regexp::Assemble
$ egrep '^.{5}$' /usr/share/dict/words 
| perl -MRegexp::Assemble -nl 
-E 'BEGIN{$ra=Regexp::Assemble->new}' 
-E '$ra->add($_);' 
-E 'END{say $ra->re}'
Wrap↑
• (?:ir)?regular expressions


• Regexp ≠ Regular Expression


• Regexp ⊆ Regular Expression


• Definition of characters


• [x00-xff]


• [u0000-uFFFF]


• [u{0000}-u{10FFFF}]


• (?:un)?availability of X


• Using perl? use CPAN!
BTW
Bible, an obsolete
• 3rd edition: August 8,
2006


• Too old especially for
JS
Thank you
🙇
Questions and answers
answer($_) foreach (/($questions)/sg);

More Related Content

What's hot

新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?
新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?
新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?naoki koyama
 
研究室における研究・実装ノウハウの共有
研究室における研究・実装ノウハウの共有研究室における研究・実装ノウハウの共有
研究室における研究・実装ノウハウの共有Naoaki Okazaki
 
Cognitive Complexity でコードの複雑さを定量的に計測しよう
Cognitive Complexity でコードの複雑さを定量的に計測しようCognitive Complexity でコードの複雑さを定量的に計測しよう
Cognitive Complexity でコードの複雑さを定量的に計測しようShuto Suzuki
 
エンジニアの個人ブランディングと技術組織
エンジニアの個人ブランディングと技術組織エンジニアの個人ブランディングと技術組織
エンジニアの個人ブランディングと技術組織Takafumi ONAKA
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなKentaro Matsui
 
Git & ブランチモデルで学ぶ バージョン管理入門
Git & ブランチモデルで学ぶ バージョン管理入門Git & ブランチモデルで学ぶ バージョン管理入門
Git & ブランチモデルで学ぶ バージョン管理入門kazuki kuriyama
 
暗号文のままで計算しよう - 準同型暗号入門 -
暗号文のままで計算しよう - 準同型暗号入門 -暗号文のままで計算しよう - 準同型暗号入門 -
暗号文のままで計算しよう - 準同型暗号入門 -MITSUNARI Shigeo
 
Pythonによる黒魔術入門
Pythonによる黒魔術入門Pythonによる黒魔術入門
Pythonによる黒魔術入門大樹 小倉
 
ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門増田 亨
 
名のあるフラクタルたち
名のあるフラクタルたち名のあるフラクタルたち
名のあるフラクタルたちYu(u)ki IWABUCHI
 
例外設計における大罪
例外設計における大罪例外設計における大罪
例外設計における大罪Takuto Wada
 
Railsのデバッグ どうやるかを改めて確認する
Railsのデバッグ どうやるかを改めて確認するRailsのデバッグ どうやるかを改めて確認する
Railsのデバッグ どうやるかを改めて確認する虎の穴 開発室
 
パタン・ランゲージを用いてスクラムの本質をひもとく
パタン・ランゲージを用いてスクラムの本質をひもとくパタン・ランゲージを用いてスクラムの本質をひもとく
パタン・ランゲージを用いてスクラムの本質をひもとくMinoru Yokomichi
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話Koichiro Matsuoka
 
トランザクションスクリプトのすすめ
トランザクションスクリプトのすすめトランザクションスクリプトのすすめ
トランザクションスクリプトのすすめpospome
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」Ken'ichi Matsui
 
オブジェクト指向プログラミングのためのモデリング入門
オブジェクト指向プログラミングのためのモデリング入門オブジェクト指向プログラミングのためのモデリング入門
オブジェクト指向プログラミングのためのモデリング入門増田 亨
 

What's hot (20)

Lean coffee
Lean coffeeLean coffee
Lean coffee
 
新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?
新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?
新たなgitのブランチモデル「Git Feature Flow」!Git Flow,Git Hub Flow,Git Lab Flowを超えれるか?
 
研究室における研究・実装ノウハウの共有
研究室における研究・実装ノウハウの共有研究室における研究・実装ノウハウの共有
研究室における研究・実装ノウハウの共有
 
Cognitive Complexity でコードの複雑さを定量的に計測しよう
Cognitive Complexity でコードの複雑さを定量的に計測しようCognitive Complexity でコードの複雑さを定量的に計測しよう
Cognitive Complexity でコードの複雑さを定量的に計測しよう
 
エンジニアの個人ブランディングと技術組織
エンジニアの個人ブランディングと技術組織エンジニアの個人ブランディングと技術組織
エンジニアの個人ブランディングと技術組織
 
テスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるなテスト文字列に「うんこ」と入れるな
テスト文字列に「うんこ」と入れるな
 
Git & ブランチモデルで学ぶ バージョン管理入門
Git & ブランチモデルで学ぶ バージョン管理入門Git & ブランチモデルで学ぶ バージョン管理入門
Git & ブランチモデルで学ぶ バージョン管理入門
 
Google Cloud で実践する SRE
Google Cloud で実践する SRE  Google Cloud で実践する SRE
Google Cloud で実践する SRE
 
暗号文のままで計算しよう - 準同型暗号入門 -
暗号文のままで計算しよう - 準同型暗号入門 -暗号文のままで計算しよう - 準同型暗号入門 -
暗号文のままで計算しよう - 準同型暗号入門 -
 
Pythonによる黒魔術入門
Pythonによる黒魔術入門Pythonによる黒魔術入門
Pythonによる黒魔術入門
 
ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門ドメイン駆動設計のためのオブジェクト指向入門
ドメイン駆動設計のためのオブジェクト指向入門
 
名のあるフラクタルたち
名のあるフラクタルたち名のあるフラクタルたち
名のあるフラクタルたち
 
例外設計における大罪
例外設計における大罪例外設計における大罪
例外設計における大罪
 
Railsのデバッグ どうやるかを改めて確認する
Railsのデバッグ どうやるかを改めて確認するRailsのデバッグ どうやるかを改めて確認する
Railsのデバッグ どうやるかを改めて確認する
 
パタン・ランゲージを用いてスクラムの本質をひもとく
パタン・ランゲージを用いてスクラムの本質をひもとくパタン・ランゲージを用いてスクラムの本質をひもとく
パタン・ランゲージを用いてスクラムの本質をひもとく
 
Tackling Complexity
Tackling ComplexityTackling Complexity
Tackling Complexity
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
 
トランザクションスクリプトのすすめ
トランザクションスクリプトのすすめトランザクションスクリプトのすすめ
トランザクションスクリプトのすすめ
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
 
オブジェクト指向プログラミングのためのモデリング入門
オブジェクト指向プログラミングのためのモデリング入門オブジェクト指向プログラミングのためのモデリング入門
オブジェクト指向プログラミングのためのモデリング入門
 

Similar to Regex Common IPv6 Address

Unicode Regular Expressions
Unicode Regular ExpressionsUnicode Regular Expressions
Unicode Regular ExpressionsNova Patch
 
Regexp secrets
Regexp secretsRegexp secrets
Regexp secretsHiro Asari
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Recursive descent parsing
Recursive descent parsingRecursive descent parsing
Recursive descent parsingBoy Baukema
 
Out with Regex, In with Tokens
Out with Regex, In with TokensOut with Regex, In with Tokens
Out with Regex, In with Tokensscoates
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Lecture 23
Lecture 23Lecture 23
Lecture 23rhshriva
 
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeProf. Wim Van Criekinge
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdatedoscon2007
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perltinypigdotcom
 

Similar to Regex Common IPv6 Address (20)

Unicode Regular Expressions
Unicode Regular ExpressionsUnicode Regular Expressions
Unicode Regular Expressions
 
Regexp secrets
Regexp secretsRegexp secrets
Regexp secrets
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Recursive descent parsing
Recursive descent parsingRecursive descent parsing
Recursive descent parsing
 
Out with Regex, In with Tokens
Out with Regex, In with TokensOut with Regex, In with Tokens
Out with Regex, In with Tokens
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekingeBioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
Bioinformatics p2-p3-perl-regexes v2013-wim_vancriekinge
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Abstract machines for great good
Abstract machines for great goodAbstract machines for great good
Abstract machines for great good
 
Regexes in .NET
Regexes in .NETRegexes in .NET
Regexes in .NET
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perl
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
 

Recently uploaded

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

Regex Common IPv6 Address

  • 2. Table of Contents • regexp? what is it? • $supported_by ~~ @most_major_languages; • but how (much)?? • Unicode support? • assertions? • modifiers? • Irregular expressions • qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))} • use CPAN; • Regexp::Assemble; • Regexp::Common; • (ir)?regular questions (?:from|by) the audience
  • 3. regexp? what is it? Mathematically speaking[*] • The empty language Ø is a regular language. • For each a ∈ Σ (a belongs to Σ), the singleton language {a} is a regular language. • If A is a regular language, A* (Kleene star) is a regular language. Due to this, the empty string language {ε} is also regular. • If A and B are regular languages, then A ∪ B (union) and A • B (concatenation) are regular languages. • No other languages over Σ are regular.
  • 4. regexp? what is it? In our language • 0 or more of… (quantifier) • '' # empty string • 'string' # any string • '(?:string|文字列)' # any alteration of strings • That's it! • ? # {0,} • + # {1,} • [0-9] # (?:0|1|2|3|4|5|6|7|8|9)
  • 5. regexp? what is it? ((?:ir)?reg(?:ular )?exp(?:ressions?)?) Visualized by: regexper.com
  • 6. regexp? what is it? (?:[x00-x7F]|[xC2-xDF][x80-xBF]|xE0[xA0-xBF][x80-xBF]|[xE1-xECxEExEF][x80-xBF]{2}|xED[x80-x9F][x80-xBF]| xF0[x90-xBF][x80-xBF]{2}|[xF1-xF3][x80-xBF]{3}|xF4[x80-x8F][x80-xBF]{2}) Exerpt from: https://www.w3.org/International/questions/qa-forms-utf-8 Visualized by: regexper.com
  • 7. regexp? what is it? (?:[+-]?)(?:0x[0-9a-fA-F]+(?:.[0-9a-fA-F]+)?(?:[pP][+-]?[0-9]+)|(?:[1-9][0-9]*)(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0(?:.0+|(?:.0+)?(?:[eE] [+-]?[0-9]+))|(?:[Nn]a[Nn]|[Ii]nf(?:inity)?)) Exerpt from: https://github.com/dankogai/js-sion/blob/main/sion.ts Visualized by: regexper.com
  • 8. Irregular expressions /^(11+?)1+$/ # is this a regular expression? $ seq 2 100 | perl -nlE 'say $_ if (1x$_) !~ /^(11+?)1+$/'
  • 9. Irregular expressions /^(11+?)1+$/ # is this a regular expression? $ seq 2 100 | perl -nlE 'say $_ if (1x$_) !~ /^(11+?)1+$/' 2 3 5 7 … 79 83 89 97
  • 10. Irregular expressions /^(11+?)1+$/ # is NOT EXACTLY a regular expression! • The problem is 1 • It is the result of the preceding capture • In other words, this expression is self-modifying. • So it is not mathematically a regular expression • Regexp ≠ Regular Expression • Regexp ⊆ Regular Expression
  • 11. Irregular expressions qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))} • Q: Can a regular expression match nested parentheses? • A: No. But some regex engines allow you to do that.
  • 12. Irregular expressions qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))} my $re = qr{( [A-Za-z_]w*s* ( ( ( (?: (?>[^()]+) | (?2) )* ) ) ) ) }x;
  • 13. Irregular expressions qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))} #!/usr/bin/env perl use strict; use warnings; use feature ':all'; my $re = qr{([A-Za-z_]w*s*((((?:(?>[^()]+)|(?2))*))))}; my $str = '$result = a(b(c),d(e,f(g,g,g)))'; $str =~ $re; say $1; say $2; say $3;
  • 14. Unicode Support What is a character? • String is /.*/ but . = • [x00-xff] # legacy world of bytes • [u0000-uFFFF] # prematurely modern • [u{0000}-u{10FFFF}] # correctly modern
  • 15. Unicode Support What is a character? • String is /.*/ but . = • [x00-xff] # Perl < 5.7 • [u0000-uFFFF] # Java(Script)?, Python2, … • [u{0000}-u{10FFFF}] # Perl, Ruby, Python3, …
  • 16. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🦏🐪🐘🐍💎⚙" =~ /(.)/g); say Dumper([@m])'
  • 17. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🦏🐪🐘🐍💎⚙" =~ /(.)/g); say Dumper([@m])' $VAR1 = [ "x{1f98f}", "x{1f42a}", "x{1f418}", "x{1f40d}", "x{1f48e}", "x{2699}" ];
  • 18. Unicode Support? What will the following say? $ node -e 'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/g))'
  • 19. Unicode Support? What will the following say? $ node -e 'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/g))' [ '', '', '', '', '', '', '', '', '', '', '⚙' ]
  • 20. Unicode Support? What will the following say? $ node -e 'console.log("🦏🐪🐘🐍💎⚙".match(/(.)/ug))' [ '🦏', '🐪', '🐘', '🐍', '💎', '⚙' ]
  • 21. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])'
  • 22. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])' $VAR1 = [ "x{1f1ef}", "x{1f1f5}", "x{1f1fa}", "x{1f1e6}" ];
  • 23. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🇯🇵🇺🇦" =~ /(.)/g); say Dumper([@m])' $VAR1 = [ "x{1f1ef}", # REGIONAL INDICATOR SYMBOL LETTER J "x{1f1f5}", # REGIONAL INDICATOR SYMBOL LETTER P "x{1f1fa}", # REGIONAL INDICATOR SYMBOL LETTER U "x{1f1e6}" # REGIONAL INDICATOR SYMBOL LETTER A ];
  • 24. Unicode Support? What will the following say? $ perl -Mutf8 -MData::Dumper -E 'my@m=("🇯🇵🇺🇦" =~ /(X)/g); say Dumper([@m])' $VAR1 = [ "x{1f1ef}x{1f1f5}", "x{1f1fa}x{1f1e6}" ];
  • 25. Unicode Support? What will the following say? $ node -e 'console.log("🇯🇵🇺🇦".match(/(.)/ug))'
  • 26. Unicode Support? What will the following say? $ node -e 'console.log("🇯🇵🇺🇦".match(/(.)/ug))' [ '🇯', '🇵', '🇺', '🇦' ]
  • 27. Unicode Support? What will the following say? $ node -e 'console.log("🇯🇵🇺🇦".match(/(X)/ug))' 🙅 [ '🇯🇵','🇺🇦' ] 🙆 SyntaxError: Invalid regular expression: /(X)/: Invalid escape at [eval]:1:24 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:305:38) at node:internal/process/execution:75:19 at [eval]-wrapper:6:22 at evalScript (node:internal/process/execution:74:60) at node:internal/main/eval_string:27:3
  • 28. 🤦
  • 29. Unicode Support? Grapheme Cluster • Defined in: • https://unicode.org/reports/tr29/ • X is supported by: • 🐘 PHP • 🐪 Perl • 💎 Ruby • Not yet supported by: • 🦏 JavaScript • 🐍 Python
  • 30. use CPAN Regexp::Common $ perl -MRegexp::Common -E 'say $RE{net}{IPv6}'
  • 31. use CPAN Regexp::Common $perl -MRegexp::Common -E 'say $RE{net}{IPv6}' (?:(?|(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a- fA-F]{1,4})|(?::(?:)(?:):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F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]{1,4}):(?:)(?:):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}))|(?:(?:[0-9a- fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:)(?:):(?:[0-9a-fA-F]{1,4}))|(?:(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a- fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:)(?:)(?:):)|(?:(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:): (?:[0-9a-fA-F]{1,4}))|(?:(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:)(?:):)|(?:(?:[0-9a-fA-F] {1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:[0-9a-fA-F]{1,4}):(?:)(?:):)))
  • 32. use CPAN Regexp::Assemble $ egrep '^.{5}$' /usr/share/dict/words | perl -MRegexp::Assemble -nl -E 'BEGIN{$ra=Regexp::Assemble->new}' -E '$ra->add($_);' -E 'END{say $ra->re}'
  • 33. Wrap↑ • (?:ir)?regular expressions • Regexp ≠ Regular Expression • Regexp ⊆ Regular Expression • Definition of characters • [x00-xff] • [u0000-uFFFF] • [u{0000}-u{10FFFF}] • (?:un)?availability of X • Using perl? use CPAN!
  • 34. BTW Bible, an obsolete • 3rd edition: August 8, 2006 • Too old especially for JS
  • 36. Questions and answers answer($_) foreach (/($questions)/sg);