473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How to change PCRE default delimiters

Hello,

I try to use alternative delimiters for a regular expression.
When will it be supported?

www@mike:/home/www > /usr/local/bin/php -a
Interactive mode enabled

<?php
preg_match('m!A(\d*)B!', 'A12345B', $X));
?>
X-Powered-By: PHP/4.2.3
Content-type: text/html

<br />
<b>Parse error</b>: parse error in <b>-</b> on line <b>2</b><br />

http://perldoc.com/perl5.8.4/pod/perlrequick.html

Best regards,
Markus Elfring
Jul 17 '05 #1
5 2720
Markus Elfring wrote:
I try to use alternative delimiters for a regular expression.
When will it be supported?

<?php
preg_match('m!A(\d*)B!', 'A12345B', $X));
?>

<b>Parse error</b>: parse error in <b>-</b> on line <b>2</b><br />


It is supported, but you have one too many brackets on the end of that
line, before the semicolon. That's what's causing the parse error.

--
Jasper Bryant-Greene
Cabbage Promotions
Jul 17 '05 #2
Markus Elfring wrote:
I try to use alternative delimiters for a regular expression.
When will it be supported?
Already is.

| The expression should be enclosed in the delimiters, a
| forward slash (/), for example. Any character can be used
| for delimiter as long as it's not alphanumeric or
| backslash (\). If the delimiter character has to be used
| in the expression itself, it needs to be escaped by
| backslash. Since PHP 4.0.4, you can also use Perl-style
| (), {}, [], and <> matching delimiters.

http://www.php.net/manual/en/ref.pcre.php

[ ... ]
preg_match('m!A(\d*)B!', 'A12345B', $X));

----------------------------------------^^
As someone else said, you've one too many there.

Use '!A(\d*)B!'. No 'm', since this isn't Perl.

[ ... ]

--
Jock
Jul 17 '05 #3
> > preg_match('m!A(\d*)B!', 'A12345B', $X));
----------------------------------------^^
As someone else said, you've one too many there.
Thanks for this hint.
I'm sorry for this nasty typo;

Use '!A(\d*)B!'. No 'm', since this isn't Perl.


Is there missing anything about "pattern delimiters" in the documentation?
http://de.php.net/manual/en/function.preg-match.php
Jul 17 '05 #4
> [ ... ]
| The expression should be enclosed in the delimiters, a
| forward slash (/), for example. Any character can be used
| for delimiter as long as it's not alphanumeric or
| backslash (\). If the delimiter character has to be used
| in the expression itself, it needs to be escaped by
| backslash. Since PHP 4.0.4, you can also use Perl-style
| (), {}, [], and <> matching delimiters.
[ ... ]


It would help if this description from the introduction will be
repeated on more pages for the other functions.
Jul 17 '05 #5
Markus Elfring wrote:

[ Re documentation of PCRE delimiters ]
It would help if this description from the introduction will be
repeated on more pages for the other functions.


Having glanced through the section again, I see where
confusion might arise; though I admit I hadn't noticed
before.

The terms 'pattern', 'regex', 'expression', and 'regular
expression' seem to be used interchangeably. The
introduction to PCREs uses the term 'expression' in the same
sense as 'pattern' is used in the separate section on
'Pattern Syntax'; but in the preg_* function docs, 'pattern'
means an opening delimiter, a pattern proper, an ending
delimiter, plus optional pattern modifiers. With more than
one name for a single thing, and a single name for more than
one thing, mystification comes as no surprise.

I trust you've sorted it out though. ;o)

--
Jock
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: news | last post by:
Hi all, I am a beginner on 'c' and pcre...and I am on windows 2000 and VC6 with all of the patches, etc. The following program leaks lots of memory and I only make 1 pcre call. I read the...
17
by: sgane2001 | last post by:
Hi, I'm using pcre.c to provide regex support for my application software. I want to know how to do 'AND' operation in this. I didn't got any useful info from the net. Is this operator...
2
by: Bernd Muent | last post by:
Hi together, most of the time I'm using .net framework to programm C++. F.E. I can do the following: Regex* rex; String*...
16
by: mainland | last post by:
I use prce to match string. I define a pcre struct point, then compile, pass pcre struct point to 'pcre_compile'. When complete, Is it necessary to use 'pcre_free' to free pcre struct point. ...
13
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone...
2
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
1
by: moreati | last post by:
Recently I discovered the re module doesn't support POSIX character classes: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.