Solved

Unknown modifier 't'

Posted on 2011-09-20
3
394 Views
Last Modified: 2012-06-22
Hi, I'm getting following error, I'm not really sure why:
Warning: preg_replace() [function.preg-replace]: Unknown modifier 't' in /include/functions.php on line 2084

This is following line:

$url_query = preg_replace('/(.*?)/strona-([0-9]*)-/', '$1/strona-'.$counter.'-', $targetpage); 

Open in new window


Thanks for any help.
0
Comment
Question by:static86
3 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 167 total points
ID: 36570704
you need to escape the /strona because your delimiter is /

so

$url_query = preg_replace('/(.*?)\/strona-([0-9]*)-/',.....

or use a different delimiter
0
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 167 total points
ID: 36570711
Alternatively, you can use different pattern delimiters:
$url_query = preg_replace('#(.*?)/strona-([0-9]*)-#', '$1/strona-'.$counter.'-', $targetpage);
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 36595288
This function can sometimes be helpful.  
http://us3.php.net/manual/en/function.preg-quote.php

But that said, the choice of the regex delimiter is usually made in such a way that it does not appear in the regex pattern.

See the code snippet for an explanation of what the regex engine is looking at in the line of code.

When you are developing regular expressions (or for that matter any complicated piece of code) a test-driven design is a really useful process.  You can see the thought process that goes into TDD in the article here.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7830-A-Quick-Tour-of-Test-Driven-Development.html
$regex = '/(.*?)/strona-([0-9]*)-/';

$regex
= '/'        // REGEX DELIMITER
. '(.*?)'    // A GROUP OF ANYTHING OR NOTHING
. '/'        // REGEX DELIMITER (OOPS)
. 'strona'   // A STRING, ETC... BUT 's' IS BEING TREATED AS A MODIFIER SINCE IT COMES AFTER THE REGEX DELIMITER.

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question