Preg_split help needed..
Posted: Mon Nov 24, 2008 3:45 pm
Hi,
I want to split the text into parts using the dot. I don't need the dot to be a part in the splitted content. Actually I want the dot be gone. This is all easy, but when it comes to taken those backslashes into consideration, it's harder...
The "\." should not be counted to be splitten... Doing something like
Will work OK, but the problem here is that the preg_split will take the character near the dot away and it does not exist in the splitted strings...
Also "text. \\. test" should be 2 parts... so I need a completely working splitting. The escaping can be anything, it might be "\\\\\\\\\\." and it must be handled correctly, MUST be...
Any help?
Code: Select all
$data = "this is a test string. This is another test. And another. But \. this hope fully does not get split up. While \\. this should be ;)";
$split = preg_split("#\\.#",$data);The "\." should not be counted to be splitten... Doing something like
Code: Select all
$split = preg_split("#[^\\]\\.#",$data);Also "text. \\. test" should be 2 parts... so I need a completely working splitting. The escaping can be anything, it might be "\\\\\\\\\\." and it must be handled correctly, MUST be...
Any help?