Goat Posted June 1, 2010 Share Posted June 1, 2010 Hello guys I would like to slice block of text using regular expressions and put parts in array. Block of text might look like this: <!--@some_str1--> <h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </h1> Proin pharetra volutpat justo, a rhoncus erat pellentesque vitae. Cras hendrerit aliquet mi nec vehicula. Integer consectetur dignissim suscipit. Vivamus et nisl erat, sit amet cursus magna. Fusce sit amet tellus vel mauris vulputate malesuada. Nullam elementum porta urna hendrerit viverra. Vivamus gravida condimentum urna, vitae interdum lacus consectetur ac. Sed accumsan bibendum metus, ut auctor justo faucibus in. <br/><br/> Fusce tristique rutrum posuere. Vivamus aliquet lacus vel sem ultricies aliquet quis vel augue. Maecenas ullamcorper purus quis nibh blandit commodo. In quis enim lectus, sed hendrerit lacus. Proin eu neque sit amet ante blandit porta. Vestibulum sodales nisl id nunc laoreet luctus. Phasellus bibendum, ipsum eu cursus facilisis, odio risus ultricies nisi, in ultrices est lorem dictum elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras bibendum accumsan vestibulum.<br/><br/> <!--@some_str2--> Sed id ullamcorper eros. Maecenas nec eros lectus. Vestibulum id enim quam, vel suscipit ipsum. Vivamus id nisl est, sit amet ultricies nulla. Cras dapibus, velit vel vestibulum tincidunt, purus libero luctus est, ut commodo dolor nisl et enim. Donec accumsan, quam non rutrum sollicitudin, orci eros porttitor mauris, vitae fermentum risus diam nec orci. Mauris non dignissim lacus. <br/><br/> <!--@some_str3--> Nulla libero dui, sodales sed porttitor quis, euismod eu magna. Curabitur lacus arcu, pulvinar vel porta eget, pulvinar adipiscing ligula. Nunc adipiscing, massa sed dictum lacinia, metus dolor gravida enim, et bibendum neque nibh quis sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse interdum aliquam felis, at semper magna dapibus ac.<br/><br/> Nulla sem orci, pulvinar ut pulvinar ut, viverra vitae dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam ac ante sit amet lacus consequat porttitor.<br/><br/> Nullam euismod leo id mi ultricies a ultricies tortor mattis. Duis suscipit neque sed nulla pellentesque sit amet molestie nisi pharetra. Nam lectus massa, malesuada in aliquet quis, tempor sit amet tellus.<br/><br/> I want to get two arrays: -One array slices text using <!--@xxxx--> as separators. So in this example we would get 3 elements containing lorem ipsum and some html. It shouldn't count <!--xxxx--> (without @) -other array only gets xxxx text. In this example there would be 3 elements: 'some_str1', 'some_str2', 'some_str3' Block of text might contain normal html tags, and I want those to remain. Thanks! regards, Goat Quote Link to comment Share on other sites More sharing options...
Goat Posted June 1, 2010 Author Share Posted June 1, 2010 --doublepost--- Quote Link to comment Share on other sites More sharing options...
Goat Posted June 1, 2010 Author Share Posted June 1, 2010 ... And there are no empty spaces or special symbols in xxxx text. Just numbers, letters and maybe _ . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.