tags:

views:

82

answers:

2

regular expression for find [# # 1] , [# # 2] ,[# # 125] .. in php

i have string

"php, regu[]lar expre[# # 1]ssio [# # 2]nssadas das dasd as das dasdssd [# # 301]dfs dfsdf sd fsdfds"

want to replace all these with {number}

A: 
theString.preg_replace( '/\([#\s#\s[0-9]+\])/', '$1' );

Edit: ok, some miner mistakes here but u get the idea :p.

palindrom
you're escaping the ( instead of the [
AutomatedTester
PHP strings are not objects
Tom Haigh
+3  A: 

In PHP you do it like this

$string=preg_replace('/\[#\s#\s([0-9]+)\]/', '$1', $string);
Christian Toma