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
0
votes
4 answers

Perl oneliner match repeating itself

I'm trying to read a specific section of a line out of a file with Perl. The file in question is of the following syntax. # Sets $USER1$ $USER1$=/usr/.... # Sets $USER2$ #$USER2$=/usr/... My oneliner is simple, perl -ne…
Tim Brigham
  • 574
  • 1
  • 6
  • 24
0
votes
2 answers

php preg_replace swap out height and width of iframe

I am trying to replace the height and width on an html iframe src upon being saved to a database. I have looked at the preg_replace function and PCRE expressions but can't work it out. Listed below is my code and sample input $pattern1 =…
revolution14
  • 43
  • 1
  • 7
0
votes
1 answer

How to enable UTF 8 Support PCRE xampp for Windows?

I am trying to get the Kohana PHP Framework to work on my localhost using xampp on windows, the problem is: PCRE UTF-8 PCRE has not been compiled with UTF-8 support. Can Anyone help me how to do this on windows? Thank you.
rootman
  • 660
  • 1
  • 8
  • 18
0
votes
1 answer

Not Operator for PCRE using php preg_replace

Is there a way to do a not operator for a PCRE in the PHP preg_replace function? I'm trying to filter a currency string (ex: $1,000.00) down to the float value (1000.00). My thought is to preg_replace on anything that is NOT 0-9 or the decimal…
Will Bonde
  • 560
  • 6
  • 19
0
votes
1 answer

I can't trigger ANTLR rule

I'm trying to build a PCRE engine, and I'm using this ANTLR grammar. These are some of its rules: octal_char : ( Backslash (D0 | D1 | D2 | D3) octal_digit octal_digit | Backslash octal_digit octal_digit ) ; octal_digit : D0 | D1 | D2 | D3…
136
  • 1,083
  • 1
  • 7
  • 14
0
votes
1 answer

Match pam file lines

I would like to parse pam files with the following two examples and look for deny configuration. auth required pam_faillock.so authsucc deny=4 even_deny_root unlock_time=1200 auth required pam_faillock.so authsucc even_deny_root…
EricStolz
  • 57
  • 1
  • 4
0
votes
1 answer

Regex: Match until "," but not if "," is inside brackets

Given the following pattern: group1: hello, group2: world group1: hello (hello, world) world, group2: world group1: hello world of the style : [, : [...]]. In general I use the following regex to…
0
votes
1 answer

Regex to return numeric value if it match one string or the other

I have a string which can come in two different ways. See the example below: # Option 1 Court Case Fee $214.00 # Option 2 Court Filing Fee: Contract $198.00 I want to build a RegEx that will return the first amount without the dollar sign. For…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
0
votes
4 answers

Perl Regex How to capture two patterns between groups

I need to match a line ONLY if it starts with the @ symbol and also contains a single 'A' character, not in a string with other characters. Just the @ and the A need, not SOA for example. Trying to this with grep -P method. Zone file fragment: @ …
0
votes
1 answer

REGEX match (split ?) NAME , CITY and TIME (<= how to parse?)

I am requesting following format from user KEYWORD , , <24:00 hour time> Point 5 is most important, I want to make sure I parse <24:00 hour time> in all possible ways that I can. What I did/want 1. Split the input to get $info (=…
wadkar
  • 960
  • 2
  • 15
  • 29
0
votes
0 answers

regex to capture group and break before an optional keyword

I am using PCRE regex and i would like to capture the string between the tag ?31 and the next ?xx tag but this next ?xx tag could be an optional tag is there anyway to make the regex to do exactly like what i want? Thanks Regex Input Captured…
smokey
  • 1
  • 1
0
votes
0 answers

Multiple nginx rewrite rule, with unknown count of parameters

I have GET request e.g. example.com/aaa/bbb/ccc/ddd/eee/fff/ggg/hhh/aaa.png and I want output like: example.com/?p1=aaa&p2=bbb&p3=ccc&p4=ddd&p5=eee&p6=fff&p7=ggg&p8=hhh&p9=aaa.png or something like this, so that I can get an array in php…
0
votes
1 answer

How can I replace two exact words separated by a whitespace using PCRE?

I've been trying to code a simple translator using Gambas and I'm stuck on replacing two exact words separated by a whitespace using PCRE, which is a built-in component on Gambas. The languages are Turkish and Uzbek. The exact phrase I want to…
0
votes
0 answers

how to fix pcre2.h: No such file or directory?

I want to use PCRE2 in my C program, but I haven't used C in a while and I can't get it to work. I'm using windows 11 and visual studio code. I downloaded pcre2 from the mirror, and used the vsc cmake extension to configure and build it. I have…
disco
  • 1
  • 1
0
votes
6 answers

REGEX if string is present then select the last character on the line

I am using PCRE. I need help developing a REGEX to select the end of the last character at the line. In my example below I am using a snippet from an XML file and I need the regex to find any lines that have 'target=' if it does then to select…
Matt_PCCI
  • 11
  • 3
1 2 3
99
100