Questions tagged [pcre]

Perl Compatible Regular Expressions(PCRE) was initially developed as a regex engine for PERL, but grew into a library that many other languages (like PHP and Apache) use for their regex. Use with the [regex] tag and any appropriate language tags.

PCRE is an initialism for Perl Compatible Regular Expressions. It is both name of a flavor and the library that implements it and makes it available for use by other programs (e.g. , ).

Despite being designed with compatibility in mind, are not 100% compatible with regular expressions (). PCRE passes many of Perl’s regression tests, though. Comparison can be found in community-authored article on Wikipedia, as suggested by PCRE homepage.

Since POSIX regex deprecation in PHP 5.3, PCRE is PHP’s only supported regex engine.

References

2401 questions
1
vote
1 answer

PCRE to replace #334455 hex with #345

I'm writing a function that replaces long hex coded color (#334455) with short one (#345). This can be only done when each color in hex is multiple of 17 (each hex pair consists of the same characters). e.g. #EEFFCC is replaced with #EFC, but…
Tom Pažourek
  • 9,582
  • 8
  • 66
  • 107
1
vote
4 answers

Shared part in RegEx matched string

In following code: "a sasas b".match(/sas/g) //returns ["sas"] The string actually include two sas strings, a [sas]as b and a sa[sas] b. How can I modify RegEx to match both? Another example: "aaaa".match(/aa/g); //actually include…
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
1
vote
1 answer

PCRE ignoring matches in c++

I'm trying to work with C++ and PCRE regular expressions in Ubuntu. I installed almost every piece of software related (libpcrepp and similar), but I can't even match the simplest expression. My code, simplified: #include #include…
1
vote
4 answers

Split string on non-alphanumerics in PHP? Is it possible with php's native function?

I was trying to split a string on non-alphanumeric characters or simple put I want to split words. The approach that immediately came to my mind is to use regular expressions. Example: $string = 'php_php-php php'; $splitArr =…
Jehanzeb.Malik
  • 3,332
  • 4
  • 25
  • 41
1
vote
2 answers

regex to separate HTML GET parameters

How can I use a regular expression to separate GET parameters in a URI and extract a certain one? Specifically, I'm trying to get just the v= part of a YouTube watch URI. I've come up with…
Blacklight Shining
  • 1,468
  • 2
  • 11
  • 28
1
vote
1 answer

How can I match a number with an optional letter suffix in a GtkSourceView language specification?

I'm writing a new GtkSourceView language specification; following the information found in the tutorial and on other internet resources. The language that I'm defining can take a digit as: One or more digit characters Optionally an appened (e.g.…
Miguel
  • 1,966
  • 2
  • 18
  • 32
1
vote
1 answer

Regex PCRE expression

I have a piece of html code like the following one: Something

needed value

Boris D. Teoharov
  • 2,319
  • 4
  • 30
  • 49
1
vote
1 answer

cppcms lots of unresolved external symbols

I am having errors as follows trying to build cppcms. Error 184 error LNK2019: unresolved external symbol __imp_pcre_compile referenced in function "public: void __cdecl booster::regex::assign(class std::basic_string,class std::allocator > const…
contrapsych
  • 1,919
  • 4
  • 29
  • 44
1
vote
2 answers

I think that this regular expression should not fail, what I'm missing?

^(?![_\.\'\-])(?:[\p{L} ]+)$ If I understand correctly, there is: (?![_\.\'\-]) a negative lookahead, that is the string cannot start with underscore, point, apostrophe or minus sign (any number of). (?:[\p{L} ]+) allowing at least one character…
gremo
  • 47,186
  • 75
  • 257
  • 421
1
vote
1 answer

Matching parenthesis content in PCRE without outermost parens

I need to extract content of unbalanced paren construction. In manual for PCRE i found solution for matching balanced parens. <\[ ( (?>[^(<\[|\]>)]+) | (?R) )* \]> For my test <[<[ab<[cd]>]><[ef]> It extracts 0.0: <[ab<[cd]>]> 0.1: <[ef]> But i…
mou
  • 73
  • 6
1
vote
0 answers

pcre error "undefined symbol: _ZN7pcrecpp2RE6no_argE"

I'm getting the following error: ./pcrecpp: symbol lookup error: ./pcrecpp: undefined symbol: _ZN7pcrecpp2RE6no_argE when run my program on CentOS 5.4. But it works well on CentOS 6.2. The version of pcre is 8.31, and the version of pcre++ is…
1
vote
1 answer

PCRE regex assistance - numerical range, with one number subtracted

I am trying to parse SIP messages for all SIP codes from the range 400-699 EXCEPT 401 (it's used for client authentication and fills our logs with garbage). The messages look like this (small subset, there's a huge number of codes and I'd like to…
Matthew
  • 512
  • 1
  • 6
  • 16
1
vote
1 answer

PCRE binary files?

I would like to parse binary files with PCRE. My tactic until now was to use fgets to read a line of a file, then parse that line using pcre_exec. This will not work for me now because the "lines" end with a null byte rather than a newline. I did…
Zombo
  • 1
  • 62
  • 391
  • 407
1
vote
4 answers

PHP REG EXP backtrack issue

I'm trying to use this reg exp in PHP in a preg_match_all /\d+ (?:<[^>]+>)(?:<[^>]+>)(\S+.*\S+)(?:<[^>]+>)\s*(\S+) (?:L|R)\s*\w* \w*\s*(?:\w+\s*){14}(\d+)\s*(\d)\s*(\d*\xA0*\d{3}\xA0*\d{3})/is There's some data sample : 38
1
vote
1 answer

How to use UTF-8 literal characters in a C/C++ PCRE Regex?

We are trying to match the German string. Munich tausendschöne Jungfräulein ausendschçne We are able to match it with a PCRE regex which uses positive lookahead and a sequence of multiple UTF-8 codepoints. For example,…
Frank
  • 1,406
  • 2
  • 16
  • 42