Using regexes for extracting data from web pages? Check out ParseHub, a visual web scraping tool built by the team behind Debuggex.
Using regexes for extracting data from web pages? Check out ParseHub, a visual web scraping tool built by the team behind Debuggex.
The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. PCRE has its own native API, as well as a set of wrapper functions that correspond to the POSIX regular expression API. The PCRE library is free, even for building proprietary software. PCRE was originally written for the Exim MTA, but is now used by many high-pr
Regex Tester is a tool to learn, build, & test Regular Expressions (RegEx / RegExp). Results update in real-time as you type. Roll over a match or expression for details. Save & share expressions with others. Explore the Library for help & examples. Undo & Redo with {{getCtrlKey()}}-Z / Y. Search for & rate Community patterns.
(2011/05/19追記)CentOS5のpcreパッケージについて言えば、2010年7月以降Unicode文字プロパティが有効になっているそうです。安心ですね!(via「 CentOS5.5でCakePHP1.3系のInflector::slugを正常動作させる方法 - Lism.in * blog - nekoya (id:studio-m)」) PCREというのは、Perl互換の正規表現ライブラリです。PCREは例えばPHPのpreg系関数で利用されていますし、他の処理系でも多く利用されているかと思います。ところで、PCREの挙動は環境ごとに異なる可能性があることをご存知でしょうか。具体的には、Unicode文字プロパティをサポートする環境としない環境とがあり、同じ正規表現でも挙動が変わることがあります。僕はそんなことを考えた事もなかったので、ビックリしました。 同じ原因で、以前の
PHP/HTML5/CSS3/JavaScript/CSS等の最新技術情報をお届け
19日(米国時間)、PCREの最新版となる「PCRE 7.2」が公開された。PCRE(Perl Compatible Regular Expressions)はPerl 5で使われている正規表現と同じ表現/機能をC言語で実装した関数のライブラリ。POSIX正規表現APIに対応したラッパ関数が用意されているほか、PCREのネイティブAPIも備える。またライブラリはThe BSD Licenseのもとオープンソースソフトウェアとして公開されている。 7.2ではPerl 5.10の正規表現からいくつかの機能「(?-n)、(?+n)、(?(-n)、(?(+n)、\k{name}、\g{name}、\K、(?|、\h、\H、\v、\V」が追加されたほか、バグの修正、パフォーマンス改善のためのリファクタリングなどが実施されている。 PCREはもともとExim MTAで活用するために開発された正規表現ラ
(2011/05/18追記)末尾にCentOSの標準RPMの更新について書きました (2011/05/19追記)続編書きました CentOS5.5でCakePHP1.3系のInflector::slugを正常動作させる方法 CakePHPのFormHelperでラジオボタンを出してみたところ、label要素がうまく動かない症状に遭遇しました。で、調べていくと斜め上な展開を見せたのでブログにまとめてみる。 検証環境はCentOS5.5 x86_64、PHPは5.2.12(自前RPM)です。CakePHPは2011/05/18現在のgithubのmasterで確認。 ■ラジオボタンがうまく選択できない CakePHPのFormHeplerでラジオボタンを出そうとして、http://book.cakephp.org/view/1429/radioのサンプルを動かしてみたところ、label要素が思
Using regexes for extracting data from web pages? Check out ParseHub, a visual web scraping tool built by the team behind Debuggex.
【速報】ヤバい?問題ない?エンジニアが知っておくべき「PCRE Heap Overflow / CVE-2015-3210」 こんにちは、せーのです。今日は結構影響の大きそうな脆弱性についての詳細な説明と現時点での対応状況をお知らせ致します。 PCREライブラリとは PCREライブラリというのは元々はPerlの正規表現と互換性のある正規表現を他の言語でも実現するために作られたライブラリで、現在はCentOSやFedora, RHEL等のLinux系のOSには標準でインストール出来る他、Apache,nginx等のミドルウェア、flash,mySql等のソフトウェア、PHP等このライブラリに依存しているパッケージは多く、システム構築をしたことのある方なら「error: pcre library is required」なんてエラーメッセージを見たことのある方もおおいのではないでしょうか。 ど
さて問題です。次のコードの実行結果はどうなるでしょうか? <?php var_dump(preg_match('/\w/u', 'あ')); var_dump(preg_match('/\w/u', ' ')); // 全角スペース var_dump(preg_match('/\w/u', '1')); // 全角の1 var_dump(preg_match('/\d/u', '1')); // 全角の1 答え。 Linux ではこうなりました。 php-4.4.9: int(0) int(0) int(0) int(0) php-5.1.6: int(0) int(0) int(0) int(0) php-5.2.17: int(0) int(0) int(0) int(0) php-5.3.0: int(0) int(0) int(0) int(0) php-5.3.1: int(0)
CakePHP 1.3.6のインストール時に見なれない黄色バーが出ました。 「PCRE has not been compiled with Unicode support.」 ということで、調べたら、 CentOS5系でPCREのUnicode properties supportがないと、ダメらしい。 (´・ω・`) < Oh... とりあえずPCREってなんだよということで 以下Wikipediaより PCRE http://ja.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions PCRE (Perl Compatible Regular Expressions) は、Perl5 互換の正規表現をC言語で実装したライブラリである。 BSDライセンスで配布されている。 元は、MTAであるEximのために書かれたものであったが、
正規表現 (Perl 互換) はじめにインストール/設定インストール手順実行時設定定義済み定数例PCRE のパターン正規表現パターンに使用可能な修飾子 — パターン修飾子Perl とは異なる点 — Perl との違いPCRE 正規表現構文 — パターン構文PCRE 関数preg_filter — 正規表現による検索と置換を行うpreg_grep — パターンにマッチする配列の要素を返すpreg_last_error — 直近の PCRE 正規表現処理のエラーコードを返すpreg_last_error_msg — 最後に実行した PCRE 正規表現に関するエラーメッセージを返すpreg_match — 正規表現によるマッチングを行うpreg_match_all — 繰り返し正規表現検索を行うpreg_quote — 正規表現文字をクオートするpreg_replace — 正規表現検索および置
Emacsの正規表現は呪いです。 なんだあのバックスラッシュの連発は… Emacs大好きでもあの 正規表現 だけは許せないという人は 僕も含め、それなりの数がいると思われます。 そんなあなたにとっておきのパッケージを紹介します。 pcre2el.el は、以下の機能をもって呪わしき正規表現から救ってくれます。 Emacsの正規表現から PCRE へ変換 Emacsの正規表現から rx (S式による表現)へ変換 正規表現を分解して文字列リスト化 カーソル位置・regionの正規表現をrx形式に変換して解説! M-x re-builder でPCREに対応!! これはそもそもelispで書かれたPCREエミュレータであり、 Emacsの正規表現に変換できる範囲でPCREが使えます。 そもそもEmacsの正規表現とPCREは一対一対応ではないので、 完全にPCREの機能が使えるわけではないですが
Perl正規表現で利用できる便利なエスケープシーケンスとして、\Qと\Eがあります。これはメタ文字の解釈を止めたり、その解釈を再開したりするものです。「man perlre」には次のような例が出てきます。 /$unquoted\Q$quoted\E$unquoted/ この正規表現は変数$unquotedと$quotedの値を利用しますが、利用のされかたが異なります。$unquotedの値はそのまま正規表現として解釈されますが、$quotedの値は文字列一致となります。 #!/usr/bin/perl -w use strict; use Data::Dumper; my $quoted = '.?'; my $unquoted = '.'; my $subject = "a.?a"; print $subject =~ /^$unquoted\Q$quoted\E$unquoted$/;
事の発端はあるバグチケットから 発端となったのはこのバグから。 Bug(バグ) #3289: 自動リンク機能で末尾のスラッシュを省略すると後続の日本語テキストもURLとしてリンクされてしまう - OpenPNE 3 - OpenPNE Issue Tracking System 大雑把に説明すると、 「http://example.comあああ」 といふ文字列に対して自動リンク機能を通したところ 「<a href="http://example.com">http://example.com</a>あああ」 ではなく 「<a href="http://example.comあああ">http://example.comあああ</a>」 のような残念な感じにリンクが張られてしまふといふバグである。 このバグを報告し終へた後、単純な正規表現のミスだらうと高を括って修正に取り掛かってゐた。が、原
現象 # /usr/local/src/httpd-2.4.2 # ./configure --prefix=/usr/local/apache2 ... configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 解決策 ダウンロードファイル一覧 - PCRE - OSDN から pcre-8.31.tar.gz をダウンロードする。 PCRE をインストールする。 # cd /usr/local/src # tar xvzf pcre-8.31.tar.gz # cd pcre-8.31 # ./configure # make # make install Apache 2.4 の configure を実行する # /usr/loc
ports How to upgrade devel/pcre regular expression library 正規表現ライブラリPCRE(deve/pcre)のportがアップデートされました。インストールされるライブラリlibpcre.soのメジャーバージョンが0から1へ変更されているため、多くのアプリケーションやライブラリが影響を受けます。PCREを採用しているライブラリやアプリケーションが多いためです。/usr/ports/UPDATINGには次のような説明が記載されています。 20120214: AFFECTS: users of devel/pcre AUTHOR: dougb@FreeBSD.org Until all dependent ports have been updated you should update pcre in a manner that wi
Use no more than 255 charactersRecent Posts CakePHP1.3.6のインストールでPCREのチェックで引っかかる 日本発NoSQL パナソニックがオンラインゲーム特化の携帯ゲーム機? Aptana Studio 3でWeb制作 オンラインゲームサービスでのISPの選び方 Archives November 2010 (2) October 2010 (1) September 2010 (2) August 2010 (5) July 2010 (15) June 2010 (2) Categories iPhone (1) Mac (3) Uncategorized (2) オンラインゲーム (10) ガジェット (3) クラウドサービス (2) データセンター (1) ネットワーク (1) 作業記録 (8) Apache (1) Ap
こんにちは、エンジニアの @hanhan1978です。 2019/05/29(水)GMO Yoursにて開催された第138回 PHP勉強会@東京 - PHP勉強会@東京 | Doorkeeperにおきまして、「PCREとPCRE-JITとPHPの話」というタイトルで発表してきました。 PHP勉強会 第138回 PCREとは? Perl互換の正規表現ライブラリのネイティブ実装です。PHPでは4系の頃からpreg_系の関数においてPCREを利用していました。 今回、個人的にPCRE-JITという正規表現のパフォーマンスを向上させるJust In Time コンパイラ周りを調べていた時に、7系以降のPHPとPCREの関係がなかなか面白いなと思ったので、まとめた次第です。 登壇スライド まとめ 正規表現は、文字列の高度で柔軟な操作をするときによく利用しますが、PHPが使っている正規表現ライブラリや
Caveat: I'm by no means a benchmarking expert; if you have tips on how to do this better I'm all ears! Search lens-regex-pcre is marginally slower than pcre-heavy, but well within acceptable margins (within 0.6%) Replace lens-regex-pcre beats pcre-heavy by ~10% Modify pcre-heavy doesn't support this operation at all, so I guess lens-regex-pcre wins here :) How can it possibly be faster if it's bas
Section: C Library Functions (3) Index Return to Main Contents 名前 pcre - Perl 互換正規表現 書式 #include <pcre.h> pcre *pcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr); pcre_extra *pcre_study(const pcre *code, int options, const char **errptr); int pcre_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int st
10. December 2011 PCRE (this is what you use when you do a preg_* call in PHP) has a plethora of newline related escape sequences and options, but only few know about those. I want to shed light on some of those options in this post. \r\n, \n and \r Okay, everyone knows about those escape sequences: \r\n is the CRLF newline Windows uses \n is the LF newline Unix uses \r is the CR newline that old
最近書いた再帰を使った正規表現を可視化しようと思ってGoogle検索してみたのですが、上位に出てくるサイトでも日本語が使えなかったりサポートしている正規表現にPCREの範囲(というか再帰)が含まれていなかったりいろいろでした いくつか正規表現の可視化サイトを試したので簡単に表にしました google: regex visualizer の検索結果上位3件を試したメモ サイト 日本語対応 正規表現の範囲 画像ダウンロード その他 Regexper ◯ 再帰はダメだった SVG, PNG Generated images licensed: CC BY 3.0と書いてあるので、生成した画像のライセンスが縛られているかも(?) Debuggex: Online visual regex tester. JavaScript, Python, and PCRE. △微妙に文字幅の計算がおかしいのか
nixCraft is a one-person operation. I create all the content myself, with no help from AI or ML. I keep the content accurate and up-to-date. Your privacy is my top priority. I don’t track you, show you ads, or spam you with emails. Just pure content in the true spirit of Linux and FLOSS. Fast and clean browsing experience. nixCraft is designed to be fast and easy to use. You won’t have to deal wit
Something to bear in mind is that regex is actually a declarative programming language like prolog : your regex is a set of rules which the regex interpreter tries to match against a string. During this matching, the interpreter will assume certain things, and continue assuming them until it comes up against a failure to match, which then causes it to backtrack. Regex assumes "greedy matching" unl
WordPress developer for Automattic, Linux fan, and all-around nerd Yesterday, I talked about how to get the most out of running regular expressions in PHP. The reason that I needed to dig in deep on regular expression syntax with PHP is because I needed to write some regular expressions that deal with Unicode characters. After much reading, I believed that I knew everything that I needed. I starte
PCRE(Perl Compatible Regular Expressions) Perl互換の正規表現ライブラリをC言語で使えるメリットは大きい。 たとえば以下の文字列からドメインより後ろのフォルダ部以降を取り出したいとする。 http://www.domain.com/folder/file.ext これをPerlの正規表現で取り出すなら ^http://([^/]+)/(.+) という表現で済む。$2という変数に目的の folder/file.ext が入る。これをC言語でやろうとすると、かなりはしょって書いても char *p; char buf[256]; p = strstr(url, "http://"); p += strlen("http://"); p = strchr(p, '/'); p++; snprintf(buf, sizeof(buf), "%s", p)
<?php if(0 < preg_match('/[\x00-\x20\x7f]/', $subject)) return false; //ASCII制御文字が含まれている 16進数でASCIIのコードを並べてます。 ただそれだけなんですが、使いたいときに、いちいちASCIIコードを確認して作るのがめんどうなのでメモ。 [\x00-\x20\x7f] 全制御文字 [\x00-\x1f\x7f] 半角スペース*1以外の制御文字 [\x00-\x09\x0b\x0c\x0e-\x1f\x7f] 半角スペースとCRとLF以外の制御文字 ASCII文字コード - IT用語辞典 他にも通したい制御文字があれば、ASCII文字コード表を元に同じように16進数で作れば出来ます。 ちょっとif文が正しいか気になったので。 <?php var_dump(0 < false); var_dump(0 <
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く