Questions tagged [pcre2]

A revised API for the PCRE library, which is a set of functions, written in C, that implement regular expression pattern matching using the same syntax and semantics as Perl, with just a few differences.

The new API is more extensible, and it was simplified by abolishing the separate "study" optimizing function; in PCRE2, patterns are automatically optimized where possible. Since forking from PCRE1, the code has been extensively refactored and new features introduced. See https://www.pcre.org/current/doc/html/pcre2.html for more details.

32 questions
3
votes
2 answers

Regex for not starting with specific word

i try to add before every word that do not have a starting [string]: to have Line: at its start so i did this regex ^(?![^:]+:) https://regex101.com/r/oMF8ks/1 and if i write 1 2 3 it returns what i want expected Line:1 Line:2 Line:3 and…
yvgwxgtyowvaiqndwo
  • 367
  • 1
  • 2
  • 10
2
votes
1 answer

Regex to get text between chapters titles in upper-case

I am trying to extract chapters/sections for txt files whose were generated using pdftotext on portuguese Lawsuits documents. Initially I tried this regex to, at least, get each chapter title: ^[A-Z\s\d\W]+$ Apparently it had worked for this…
celsowm
  • 846
  • 9
  • 34
  • 59
2
votes
1 answer

pcre2: include a static library in c++ CMake project

need to include pcre2 static library in my CMake project. I've built last version of pcre2 from official sources and got libpcre2-32.a (I need 32-bit char width libray) Put it in my project folder, with its header pcre2.h Have added this library to…
sinoptic
  • 303
  • 3
  • 12
1
vote
1 answer

Problems trying to create a regex for getting legislation references

I am trying to create a regex for getting legislation references in pt-br like: Lei 11.738/2008 Lei nº 9.394/96 Lei Estadual nº 6.834 Lei 5.539/2009 Decreto 30.825/2002 Lei 1614 de 21 de janeiro de 1990 art. 1.039 do CPC/2015 ps.: lei (law),…
celsowm
  • 846
  • 9
  • 34
  • 59
1
vote
1 answer

Regexp find a match with priority order but same captured group

I have the same problem as the one in the link but in PCRE2 (regex101.com): Regexp find a match with priority order? I have: /.*?(hello)|.*?(hey)|.*?(hi)/ms hi hey hello But the problem is that when it finds hello, it is stored in group 1, when it…
Mario Palumbo
  • 693
  • 8
  • 32
1
vote
2 answers

Valgrind conditional jump ... error with PCRE2 JIT when reading from file

I have a very interesting problem. I'd like to use PCRE2, and its JIT function. The task is simple: read lines from a file, and find patterns. Here is the sample code: #include #include #define PCRE2_CODE_UNIT_WIDTH 8 #include…
airween
  • 6,203
  • 1
  • 14
  • 20
1
vote
2 answers

Match first and last "yes" as well as all "no"

I need PCRE2 regex to find all occurences of "no" as well as first and last occurences of "yes". Expected results: "no/yes" - expect two matches: "no" and "yes" "no/yes/word/yes/no" - expect four matches: "no", "yes", "yes",…
klee
  • 55
  • 6
1
vote
1 answer

How do you set output size in pcre2_substitute

I use pcre2_substitute in C. PCRE2_SPTR pattern; PCRE2_SPTR replacement; PCRE2_SPTR subject; pcre2_code *re; int errornumber; int i; int rc; PCRE2_SIZE erroroffset; PCRE2_SIZE *ovector; size_t subject_length; size_t replacement_length =…
Googlebot
  • 15,159
  • 44
  • 133
  • 229
1
vote
0 answers

C function to search and replace with and without callbacks

So, I'm working on a preprocessor for C, my post on another site went semi viral (cprogramming.com) What I want is a function, using PCRE2, that replaces a string with another string. I also want a function that replaces a string with the result of…
1
vote
3 answers

Regex multiline match excluding lines containing a string

In the following regex: EXCLUDE this entire line include this line and this as single match and EXCLUDE this line I want to return a single match consisting for two lines: include this line and this as single match I want to use EXCLUDE as string…
Chebz
  • 1,375
  • 3
  • 14
  • 27
1
vote
2 answers

How to retrieve the captured substrings from a capturing group that may repeat?

I'm sorry I found it difficult to express this question with my poor English. So, let's go directly to a simple example. Assume we have a subject string "apple:banana:cherry:durian". We want to match the subject and have $1, $2, $3 and $4 become…
Cody
  • 609
  • 4
  • 21
0
votes
1 answer

Creating a Splunk Alert Pulling important information from a field using Regex

I am creating a Splunk alert for Active Directory events when anything gets moved. I am having troubles with implementing regex on the search. So I created a regex like…
0
votes
1 answer

Why is PCRE2 on Ubuntu installed in /usr/lib

When I install PCRE2 on a Red Hat, PCRE2 is installed in /usr/lib64. The libpcre2-8.so is 64 bit so it seems logical to install it in /usr/lib64. However, when I do the same on Ubuntu 20.04, it installs it in /usr/lib. Why is that? Ubuntu is 64 bit,…
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
0
votes
0 answers

PHP 8.1 - Rocky Linux 9 - preg_replace(): Compilation failed: unrecognised compile-time option bit(s) at offset 0

Setup Rocky Linux 9 PHP 8.1 MySQL 8 Wordpress 6.2 I am attempting to install Wordpress on a brand new server I opened. But I'm getting the following warnings/errors when I visit the install page: [18-May-2023 01:26:09 UTC] PHP Warning:…
Josh Whitlow
  • 481
  • 6
  • 25
0
votes
2 answers

PCRE2 (PHP>=7.3) Positive Lookbehind Regex to search for strings separated by ","

I have this string: 'newProductsInfo: [[1] - $2 dollars,[2] New Product,[3] Hello,[4]Same, [5]Value]' The word 'newProductsInfo', and a space ' ' always precede the array of strings. I want to be able to return [1] - $2 dollars [2] New…
Prosy Arceno
  • 2,616
  • 1
  • 8
  • 32
1
2 3