Need regex for multiple carriage returns
Moderator: General Moderators
Need regex for multiple carriage returns
I have a text file that has the info seperated by 2 carriage returns. I read the whole file in with file_get_contents then I do another regex to get like the chapters seperated. Then each chapter has different sections that are seperated by 2 carriage returns. I can not figure out how to split the content with the returns can anyone help me?
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Need regex for multiple carriage returns
Split on the occurrence of two of the following (succeeding) patterns:
Code: Select all
'/\r\n|[\r\n]/'Re: Need regex for multiple carriage returns
I am not very good to regex. What do you mean split on occurence of 2 of those.
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Need regex for multiple carriage returns
Now is a good time to learn something:Extremest wrote:I am not very good to regex. What do you mean split on occurence of 2 of those.
http://nl2.php.net/preg_split
http://www.regular-expressions.info/repeat.html (see the paragraph "Limiting Repetition")
Re: Need regex for multiple carriage returns
I have tried using what he has with {2} behind it meaning it needs to have 2 of them right. It is not splitting it though. Is there a text editor out there that will show you which returns it has.
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Need regex for multiple carriage returns
Can you provide the sample text you're testing your regex against and explain what is going wrong?Extremest wrote:I have tried using what he has with {2} behind it meaning it needs to have 2 of them right. It is not splitting it though. Is there a text editor out there that will show you which returns it has.