Solved

Unknown modifier 't'

Posted on 2011-09-20
3
408 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
can i read my emails on lamp ftp 4 71
How difficult would it be build a cookie scanner in PHP? 21 63
php hashing methods 3 50
P3P validator , ASP, PHP ,Https and Http links 3 47
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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 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