/[<">

perl程序设计技巧

Jun 07, 2016 pm 03:23 PM
pass perl poe スキル プログラミング

1. Why does POE pass parameters as array slices? http://poe.perl.org/?POE_FAQ/calling_convention 2. perl regular expression fast referecnces metacharacters are {}[]() ^ $ . | * + ? a metacharacter can be matched by putting a backslash befo

1. Why does POE pass parameters as array slices?
http://poe.perl.org/?POE_FAQ/calling_convention

2.  perl regular expression fast referecnces
metacharacters are

perl程序设计技巧{ } [ ] ( ) ^ $ . |  * + ? 

a metacharacter can be matched by putting a backslash before it
anchor metacharacters ^ and $ .
The anchor ^ means match at the beginning of the string and the anchor $ means match at the end of the string, or before a newline at the end of the string.

perl程序设计技巧"housekeeper" =~ /keeper/;          # matches
perl程序设计技巧
"housekeeper" =~ /^keeper/;        # doesn't match
perl程序设计技巧
"housekeeper" =~ /keeper$/;        # matches
perl程序设计技巧
"housekeeper " =~ /keeper$/;    # matchesperl程序设计技巧

A character class allows a set of possible characters, rather than just a single character, to match at a particular point in a regexp.Character classes are denoted by brackets [...], with the set of characters to be possiblly matched inside. Some examples:

perl程序设计技巧/cat/;      #matches 'cat'
perl程序设计技巧
/[bcr]at/;  #matches 'bat', 'cat', or 'rat'
perl程序设计技巧
/item[0123456789]/;   #matches 'item0' or ... or 'item9'
perl程序设计技巧
"abc" =~ /[cab]/;  #matches 'a'
perl程序设计技巧
/[yY][eE][sS]/ can be rewritten as /yes/i.

The 'i' stands for case-insensitive and is an example of a modifier of the matching operation.
The special characters for a character class are - ] / ^ $ (and the pattern delimiter, whatever it is). ] is special because it denotes the end of a character class. $ is special because it denotes a scalar variable. / is special because it is used in escape sequences.

perl程序设计技巧/[/]c]def/# matches ']def' or 'cdef'
perl程序设计技巧
   $x = 'bcr';
perl程序设计技巧   
/[$x]at/;   # matches 'bat', 'cat', or 'rat'
perl程序设计技巧
   /[/$x]at/;  # matches '$at' or 'xat'
perl程序设计技巧
   /[//$x]at/# matches '/at', 'bat, 'cat', or 'rat'

The specia character '-' acts as a range operator within a character class.

perl程序设计技巧/item[0-9]/;  # matches 'item0' or ... or 'item9'
perl程序设计技巧
/[0-9bx-z]aa/;  # matches '0aa', ..., '9aa',
perl程序设计技巧                    # 'baa', 'xaa', 'yaa', or 'zaa'

   /[0-9a-fA-F]/;  # matches a hexadecimal digit
   /[0-9a-zA-Z_]/# matches a "word" character,
perl程序设计技巧                    # like those in a Perl variable name

If '-' is the first or last character in a character class, it is treated as an ordinary character; [-ab], [ab-] and [a/-b] are all equivalent.
The special character ^ in the first position of a character class denotes a negated character class, which matches any characters but those in the brackets.

perl程序设计技巧    /[^a]at/;  # doesn't match 'aat' or 'at', but matches
perl程序设计技巧               # all other 'bat', 'cat, '0at', '%at', etc.

perl程序设计技巧
    /[^0-9]/;  # matches a non-numeric character
perl程序设计技巧
    /[a^]at/;  # matches 'aat' or '^at'; here '^' is ordinary

perl程序设计技巧/d matches a digit, not just [0-9] but also digits from non-roman scripts
perl程序设计技巧/
s matches a whitespace character, the set [/ /t/r/n/f] and others
perl程序设计技巧/
w matches a word character (alphanumeric or _), not just [0-9a-zA-Z_] but also digits and 
perl程序设计技巧     characters from non
-roman scripts
perl程序设计技巧/
D is a negated /d; it represents any other character than a digit, or [^/d]
perl程序设计技巧/
S is a negated /s; it represents any non-whitespace character [^/s]
perl程序设计技巧/
W is a negated /w; it represents any non-word character [^/w]
perl程序设计技巧The period 
'.' matches any character but "/n" (unless the modifier //s is in effect, as explained
perl程序设计技巧below)
.

perl程序设计技巧    //d/d:/d/d:/d/d/# matches a hh:mm:ss time format
perl程序设计技巧
    /[/d/s]/;         # matches any digit or whitespace character
perl程序设计技巧
    //w/W/w/;         # matches a word char, followed by a
perl程序设计技巧                      # non-word char, followed by a word char

perl程序设计技巧
    /..rt/;           # matches any two chars, followed by 'rt'
perl程序设计技巧
    /end/./;          # matches 'end.'
perl程序设计技巧
    /end[.]/;         # same thing, matches 'end.'

The alternation metacharacter | .To match dog or cat, we  form the
regexp dog|cat. As before, Perl will try to match the  regexp at the earliest possible point in the
string. At each  character position, Perl will first try to match the first  alternative, dog. If dog doesn't
match, Perl will then try the  next alternative, cat. If cat doesn't match either, then the  match fails and
Perl moves to the next position in the string.

perl程序设计技巧    "cats and dogs" =~ /cat|dog|bird/;  # matches "cat"
perl程序设计技巧
    "cats and dogs" =~ /dog|cat|bird/;  # matches "cat"

() is grouping metacharacter.

perl程序设计技巧    /(a|b)b/;    # matches 'ab' or 'bb'
perl程序设计技巧
    /(ac|b)b/;   # matches 'acb' or 'bb'
perl程序设计技巧
    /(^a|b)c/;   # matches 'ac' at start of string or 'bc' anywhere
perl程序设计技巧
    /(a|[bc])d/# matches 'ad', 'bd', or 'cd'
perl程序设计技巧
    /house(cat|)/;  # matches either 'housecat' or 'house'
perl程序设计技巧
    /house(cat(s|)|)/;  # matches either 'housecats' or 'housecat' or
perl程序设计技巧                        # 'house'.  Note groups can be nested.

perl程序设计技巧
    /(19|20|)/d/d/;  # match years 19xx, 20xx, or the Y2K problem, xx
perl程序设计技巧
    "20" =~ /(19|20|)/d/d/;  # matches the null alternative '()dd',
perl程序设计技巧                             # because '20dd' can't match

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

Win11 ヒントの共有: ワン トリックで Microsoft アカウントのログインをスキップする Win11 ヒントの共有: ワン トリックで Microsoft アカウントのログインをスキップする Mar 27, 2024 pm 02:57 PM

Win11 のヒントの共有: Microsoft アカウントのログインをスキップする 1 つのトリック Windows 11 は、新しいデザイン スタイルと多くの実用的な機能を備えた、Microsoft によって発売された最新のオペレーティング システムです。ただし、一部のユーザーにとっては、システムを起動するたびに Microsoft アカウントにログインしなければならないのが少し煩わしい場合があります。あなたがそのような人であれば、次のヒントを試してみるとよいでしょう。これにより、Microsoft アカウントでのログインをスキップして、デスクトップ インターフェイスに直接入ることができるようになります。まず、Microsoft アカウントの代わりにログインするためのローカル アカウントをシステムに作成する必要があります。これを行う利点は、

ベテラン必携:C言語の*と&のヒントと注意点 ベテラン必携:C言語の*と&のヒントと注意点 Apr 04, 2024 am 08:21 AM

C 言語では、他の変数のアドレスを格納するポインタを表し、& は変数のメモリ アドレスを返すアドレス演算子を表します。ポインタの使用に関するヒントには、ポインタの定義、ポインタの逆参照、ポインタが有効なアドレスを指していることの確認が含まれます。アドレス演算子の使用に関するヒントには、変数アドレスの取得、配列要素のアドレスを取得するときに配列の最初の要素のアドレスを返すことなどが含まれます。 。ポインター演算子とアドレス演算子を使用して文字列を反転する実際の例。

初心者がフォームを作成するためのヒントは何ですか? 初心者がフォームを作成するためのヒントは何ですか? Mar 21, 2024 am 09:11 AM

私たちは Excel で表を作成したり編集したりすることがよくありますが、ソフトウェアに触れたばかりの初心者にとって、Excel を使用して表を作成する方法は私たちほど簡単ではありません。以下では、初心者、つまり初心者がマスターする必要があるテーブル作成のいくつかの手順について演習を行います。初心者向けのサンプルフォームを以下に示します。入力方法を見てみましょう。 1. Excel ドキュメントを新規作成するには 2 つの方法があります。 [デスクトップ]-[新規作成]-[xls]ファイル上の何もない場所でマウスを右クリックします。 [スタート]-[すべてのプログラム]-[Microsoft Office]-[Microsoft Excel 20**] を実行することもできます。 2. 新しい ex ファイルをダブルクリックします。

VSCode 入門ガイド: 初心者が使い方のスキルをすぐにマスターするための必読の書です。 VSCode 入門ガイド: 初心者が使い方のスキルをすぐにマスターするための必読の書です。 Mar 26, 2024 am 08:21 AM

VSCode (Visual Studio Code) は、Microsoft によって開発されたオープン ソース コード エディターであり、強力な機能と豊富なプラグイン サポートを備えており、開発者にとって推奨されるツールの 1 つです。この記事では、初心者が VSCode の使用スキルをすぐに習得できるようにするための入門ガイドを提供します。この記事では、VSCode のインストール方法、基本的な編集操作、ショートカット キー、プラグインのインストールなどを紹介し、具体的なコード例を読者に提供します。 1. まず VSCode をインストールします。

Win11 の裏技が明らかに: Microsoft アカウントのログインをバイパスする方法 Win11 の裏技が明らかに: Microsoft アカウントのログインをバイパスする方法 Mar 27, 2024 pm 07:57 PM

Win11 のトリックが明らかに: Microsoft アカウントのログインをバイパスする方法 最近、Microsoft は新しいオペレーティング システム Windows11 を発表し、広く注目を集めています。以前のバージョンと比較して、Windows 11 はインターフェイスのデザインや機能の改善の点で多くの新しい調整を加えましたが、いくつかの議論も引き起こしました. 最も目を引く点は、ユーザーが Microsoft アカウントでシステムにログインすることを強制することです。ユーザーによっては、ローカル アカウントでログインすることに慣れており、個人情報を Microsoft アカウントにバインドすることに抵抗がある場合があります。

PHP プログラミング スキル: 3 秒以内に Web ページにジャンプする方法 PHP プログラミング スキル: 3 秒以内に Web ページにジャンプする方法 Mar 24, 2024 am 09:18 AM

タイトル: PHP プログラミングのヒント: 3 秒以内に Web ページにジャンプする方法 Web 開発では、一定時間内に別のページに自動的にジャンプする必要がある状況によく遭遇します。この記事では、PHP を使用して 3 秒以内にページにジャンプするプログラミング手法を実装する方法と、具体的なコード例を紹介します。まず、ページ ジャンプの基本原理は、HTTP 応答ヘッダーの Location フィールドを通じて実現されます。このフィールドを設定すると、ブラウザは指定されたページに自動的にジャンプできます。以下は、P の使用方法を示す簡単な例です。

今週のダークな乱闘: POE が新しいシーズンを開始します! Diablo モバイル ゲームが自動ハングアップ機能を開始 今週のダークな乱闘: POE が新しいシーズンを開始します! Diablo モバイル ゲームが自動ハングアップ機能を開始 Mar 25, 2024 pm 06:31 PM

XGPでの『Diablo 4』と『Path of Exile』の発売に伴い、多くの新情報が公開されました。 3 月の最終週には、ディアブロのようなゲームのユーザーを獲得するための新たな戦いが見られるでしょう。まずは発売から1年が経ち、愛されたり嫌われたりしている『ディアブロ 4』についてお話しましょう。半年前から予告されていたレイトレーシング機能が、いよいよ3月26日に正式にゲームに追加される。新しいレイ トレーシング エフェクトは、鎧、水、窓、その他の反射面でのレイ トレーシングによる反射や、レイ トレーシングによるシャドウなど、さまざまな視覚的な強化をもたらします。ただし、ライト トレース特殊効果にはグラフィック カード リソースに対する高い要件があるため、コンピューターの構成が対応する標準を満たしていない場合、ゲームをスムーズに実行することが困難になる可能性があります。 3 月 28 日、「ディアブロ 4」が正式に Ga に参加します

Laravel フォームクラスを使用するためのヒント: 効率を向上させる方法 Laravel フォームクラスを使用するためのヒント: 効率を向上させる方法 Mar 11, 2024 pm 12:51 PM

フォームは、Web サイトまたはアプリケーションの作成に不可欠な部分です。 Laravel は人気のある PHP フレームワークとして、豊富で強力なフォーム クラスを提供し、フォーム処理をより簡単かつ効率的にします。この記事では、Laravel フォームクラスを使用して開発効率を向上させるためのヒントをいくつか紹介します。以下、具体的なコード例を挙げて詳しく説明します。フォームの作成 Laravel でフォームを作成するには、まずビューに対応する HTML フォームを記述する必要があります。フォームを操作するときは、Laravel を使用できます

See all articles