home > 比較編 > Perl, PHP, Python, Ruby > regular expresions >

ForNext

Only Do What Only You Can Do

074. group capture

VBScript

JScript

Perl

$rx = qr/(\d{4})-(\d{2})-(\d{2})/;
"2010-06-03" =~ $rx;
($yr, $mo, $dy) = ($1, $2, $3);

PHP

$s = "2010-06-03";
$rx = '/(\d{4})-(\d{2})-(\d{2})/';
preg_match($rx, $s, $m);
list($_, $yr, $mo, $dy) = $m;

Python

rx = '(\d{4})-(\d{2})-(\d{2})'
m = re.search(rx, '2010-06-03')
yr, mo, dy = m.groups()

Ruby

rx = /(\d{4})-(\d{2})-(\d{2})/
m = rx.match("2010-06-03")
yr, mo, dy = m[1..3]

PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system