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
2 answers

PCRE pattern to count number of character(s)

here is my input string: bar somthing foo bar somthing foo I would like to count number of a character (ex: 't') between bar & foo bar somthing foo -> 1 bar somthing foo -> 1 I know we can use /bar(.*?)foo/ and then count number of character in…
tqwer
  • 103
  • 1
  • 2
  • 9
0
votes
3 answers

PCRE - First match

I'm using grep to extract parts from a file but I'm having trouble making it work properly. From a string, something0( something1 I want to extract something0. This works fine on some input, echo 'a b( c d' | grep -Po '(?m)^.+?(?=\(.+)' #outputs…
user1260358
0
votes
2 answers

Using pcre in a c program on windows

I am trying to build an appliction based upon the pcredemo application. When I try and compile the application in Windows I get the following compiler errors. undefined reference to `_imp__pcre_compile'| undefined reference to…
Dunc
  • 7,688
  • 10
  • 31
  • 38
0
votes
2 answers

Matching order in PCRE

How can I set which order to match things in a PCRE regular expression? I have a dynamic regular expression that a user can supply that is used to extract two values from a string and stores them in two strings. However, there are cases where the…
toastie
  • 1,934
  • 3
  • 22
  • 35
0
votes
2 answers

How can I get a string between some tags, but BEFORE "", with a regex?

/(?:.*?)value="(.*?)"(?:.*?)(.*?)<\/td>(?:.*)(?:(.*?)<\/td>)+(?:.*?)<\/table>/ This is my current regex string, used in PHP with…
Bogdacutu
  • 763
  • 7
  • 24
0
votes
3 answers

How to make regular expression for this?

I want to make a regular expression to match a string like : Function_Name ( 'parameters' ) Function Description so I get the name, parameters and description.
K7rim
  • 147
  • 10
0
votes
5 answers

How do I avoid capturing the primary group of a given regex pattern?

I have a regexp pattern: <^(([a-z]+)\:([0-9]+)\/?.*)$> How do I avoid capturing the primary group? <^(?:([a-z]+)\:([0-9]+)\/?.*)$> The above pattern will still put the whole string 'localhost:8080' into the first (0) group. But I need to get only…
Aleksandr Makov
  • 2,820
  • 3
  • 37
  • 62
0
votes
2 answers

Need a simple regex

Hi I need a Simple Regular expression in PCRE format to match something like (Child OR Children) AND toys
Michael M
  • 1
  • 1
0
votes
1 answer

Is `^/` a chracter type in PCRE?

Is ^/ a chracter type in PCRE? Have seen it get mentioned in character classes. e.g. [^/]*. Cannot find anything in Documentation
ThinkingMonkey
  • 12,539
  • 13
  • 57
  • 81
0
votes
1 answer

preg_match() adding nonsense character

I'm trying to match DMS latitude/longitude. I've run into a bit of a snag, though. I can detect the pattern so far, but the match keeps returning a nonsense character next to a special character. Here is my code: //Begin code $pattern =…
rogue780
  • 155
  • 1
  • 1
  • 9
0
votes
1 answer

Non-standard urls with Yii urlManager

I need to use urls like ., for example: api.wwwhost.com/index.php?r=people.top So, I've tried to write pattern 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'caseSensitive'=>false, …
Mark Pegasov
  • 5,109
  • 9
  • 26
  • 30
0
votes
2 answers

What does `&` signify in PCRE?

Tried searching in PCRE Documentation. Couldn't find anything. What does & signify in PCRE? Saw a usage of it in an expression like this: (^|&)p=(about_us|contact)(&|$) [NC] in this question: RewriteCond %{REQUEST_URI} : how to stop, if REQUEST_URI…
ThinkingMonkey
  • 12,539
  • 13
  • 57
  • 81
0
votes
8 answers

How get last segment of url using PCRE?

I have a url, - "http://example.com/sales/view/id/705" and I need get a last segment (705). How can I do this using PCRE?
NiLL
  • 13,645
  • 14
  • 46
  • 59
0
votes
2 answers

Regular expression for LaTeX with escaped } (curly brace) needed

I just started to write a C program converting some LaTeX into HTML code. The best way in my opinion is to use regular expressions, yet I cannot make this simple idea work with PCRE: Replace something like \term{abc} by [pre]abc[/pre] (\term is a…
smiter
  • 3
  • 1
0
votes
5 answers

Regular expression to count the number of % or = or : in a string of any length

I'm looking for help in crafting a regular expression that detects a count of 10 (or more) of the characters '%' or '=' or ':' in a string of any length. Thus far, I've checked the following sources but couldn't seem to adapt what was posted to my…
James
  • 23
  • 1
1 2 3
99
100