watsmyname Posted November 16, 2009 Share Posted November 16, 2009 well, my problem is i have a long sentence, and in sentence there might be more than one word enclosed in single quotes. All i want to do is get all word enclosed in single quotes and put them in an array. Can anybody help me out? Thanks Quote Link to comment Share on other sites More sharing options...
Garethp Posted November 16, 2009 Share Posted November 16, 2009 preg_match_all('~\'(.*?)\'~', $Input, $Matches); Quote Link to comment Share on other sites More sharing options...
watsmyname Posted November 16, 2009 Author Share Posted November 16, 2009 preg_match_all('~\'(.*?)\'~', $Input, $Matches); Thanks for the reply, That was too close to my solution, now i need to find words in quotes and append some other text to these words. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted November 16, 2009 Share Posted November 16, 2009 preg_match_all('~\'(.*?)\'~', $Input, $Matches); 'Foo said \'hi bar\'' preg_match_all('#\'((?:[^\'\\\\]|\\\\.)*)\'#', $string, $matches); Quote Link to comment Share on other sites More sharing options...
salathe Posted November 16, 2009 Share Posted November 16, 2009 That was too close to my solution, now i need to find words in quotes and append some other text to these words. Please don't change the requirements, it is a common problem here. Please, in detail, describe what you want to achieve. It sounds like you want to match words enclosed in quotes (single, double or both?) and add some text after them. E.g. given "blah 'hello' blah" you want some output like "blah 'hello' text blah"? @Daniel0, lets get the question straight with the OP before looking at things like that, don't want to confuse them (or us, more). 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.