Solved

Unknown modifier 't'

Posted on 2011-09-20
3
413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

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…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

632 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