PCRE
| Autor | Philip Hazel |
|---|---|
| Aktualna wersja stabilna | 10.47 (21 października 2025) [±] |
| System operacyjny | POSIX |
| Rodzaj | Biblioteka wyrażeń regularnych |
| Licencja | BSD |
| Strona internetowa | |
Perl Compatible Regular Expressions (PCRE) – biblioteka udostępniająca Perlowe wyrażenia regularne programom w C oraz skrypt, który udostępnia je z poziomu powłoki.
PCRE posiada zarówno swój własny interfejs, jak i interfejs kompatybilny z wyrażeniami regularnymi POSIX.
Jest ona używana m.in. przez KDE, exim, PHP i tin.
Przykład użycia (interfejs POSIX-owy):
#include <pcreposix.h>
#include <stdio.h>
int main(void)
{
regex_t rx;
char *pat = "([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})";
// More "ambitious" expression - "(?:([0-2]?\\d{1,2})\\.){3}([0-2]?\\d{1,2})";
char *str = "123.45.67.89";
regmatch_t match [6];
int i;
regcomp (&rx, pat, 0);
regexec (&rx, str, 6, match, 0);
for (i=0; i<6; ++i)
{
printf ("Perl-Compatible Regular Expression matched from character %i to %i: `%.*s'\n",
match[i].rm_so, match[i].rm_eo,
match[i].rm_eo-match[i].rm_so,
&str[match[i].rm_so]);
}
return 0;
}
Linki zewnętrzne
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.