Alright, since I wanted to test my skills in regex, I tried to get the contents between <textarea></textarea> for some reason it doesn't work. Since the file is very big, I have uploaded it on pastebin. Would appreciate any help. Link to php file - http://pastebin.com/m2e41cd54
Adding the non-greedy modifier (?) to your first sub-match (.*) fixes it. preg_match('#<textarea(.*?)>(.*)</textarea>#s', $test, $match); PHP: Alternatively, you could make the entire match non-greedy by using the U pattern modifier ending. preg_match('#<textarea(.*?)>(.*)</textarea>#Us', $test, $match); PHP: Try reading this to learn more about non-greedy modifiers