Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unknown modifier 't'

Posted on 2011-09-20
3
Medium Priority
?
420 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 668 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 668 total points
ID: 36570711
Alternatively, you can use different pattern delimiters:
$url_query = preg_replace('#(.*?)/strona-([0-9]*)-#', '$1/strona-'.$counter.'-', $targetpage);
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 664 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

972 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