regex
anyone can help me to make regular expression
[code ]
$string="
xxxxx
xxxxx
";
i want to remove all word from that string if that string have minimal three word'x'
preg_replace(); how to make that regex?
forzadraco
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
i want to remove all word from that string if that string have minimal three word'x'
I am not clear what you want. Do you want to search for xxx, if found, remove it ?
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
yes remove all if get same pattern.. the problem is how to make regex pattern...
forzadraco
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
$pattern = "/x{3}/";
$string = preg_replace($pattern,'', $string);
This will look for xxx, if found, replaces it with null.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
not like that.. iwant to remove all from if match with the pattern..
the pattern from
forzadraco
Junior Poster in Training
70 posts since Mar 2008
Reputation Points: 10
Solved Threads: 1
This isn't the best solution (Infact, its kinda sloppy!). First, use preg_match to search for pattern "xxx". If found, then, use preg_match again, but this time, search for pattern, '/. This will again return the string between
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356