Error with regular expression in PHP

4

Would anyone know to tell me why this regular expression of the error in PHP?

/:[^\/\]*/

It is being used this way:

return '/' . preg_replace('/:[^\/\]*/', '([^\/]*)', $value) . '/';

I'm trying to "break" one counter against another but PHP behaves as if it were breaking the "" character and returns me the error: "Compilation failed: missing terminating for character class".

Is there another way I can specify a counter literal in a regular PHP expression?

    
asked by anonymous 03.05.2014 / 20:51

2 answers

4

Use the regular expression like this:

/:[^\/\\]*/

References:

03.05.2014 / 21:47
3

What do you want to do? It looks like you want to parse in url. If so, use parse_url

link

If not, use the explode ("/", $ value)

If it is to escape, use the url functions

link

The use of regular expression in php can be replaced by several other methods of better understanding and functioning

Add examples of $ value, and what should be the output

    
03.05.2014 / 21:25