preg_match_all expression help

Hi experts

I have regular expression for in my pregmatch below.
What i am trying to do it to add the <br/> to the expression so that i can match on that aswell to produce the follow

2:In the name of love?
3:Before you<br/>
4:break my heart

But as you guessed I CANT DO IT :( urghhhhhhhh

can anyone help?


$paragraph = "Stop! In the name of love? Before you<br/>break my heart";
preg_match_all("# ?([a-z ]+[\.\?!])#i",$paragraph,$sentance);

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this,

This prints,

    [0] => Array
            [0] => Stop!
            [1] =>  In the name of love?
            [2] =>  Before you<br/>
            [3] => break my heart

    [1] => Array
            [0] => Stop!
            [1] => In the name of love?
            [2] => Before you<br/>
            [3] => break my heart

$paragraph = "Stop! In the name of love? Before you<br/>break my heart";
preg_match_all("# ?([a-z ]+(?:[\.\?!]|(?:<br/>))*)#ui",$paragraph,$sentance);
//preg_match_all("# ?([a-z ]+([\.\?!]|(<br/>))*)#ui",$paragraph,$sentance);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
preg_split("/([.?\n])/", $paragraph, -1, PREG_SPLIT_DELIM_CAPTURE); or something like that. If I understand your question.
This will split the string on ! ? or <br/> and trim any spaces from the start of each string:
$sentence = preg_split('%(?:[!?]|<br ?/?>) ?%i', $paragraph);

Open in new window

Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Sorry, the delimiters are missing. This:

header('content-type: text/plain');
$paragraph = 'Stop! In the name of love? Before you<br/>break my heart';
$sentence = preg_split('%(?:(?<=[!?])|(?<=<br/>)) ?%i', $paragraph);

Open in new window


array(4) {
  string(5) "Stop!"
  string(20) "In the name of love?"
  string(15) "Before you<br/>"
  string(14) "break my heart"

Open in new window

you can also try this simple regex [\w\s]+[!\?]?

or more php-ish /[\w\s]+[!\?]?/

/([\w\s]+)[!\?]?/ -> with capturing groups
noam_dz: That regex does not detect the <br/> as requested in the question.
handypamAuthor Commented:
thanks for your help experts....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.