Split string into sentences using regex

前端 未结 6 1964
挽巷
挽巷 2020-11-28 10:54

I have random text stored in $sentences. Using regex, I want to split the text into sentences, see:

function splitSentences($text) {
    $re = \         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 11:35

    Henrik Petterson Please read it completely because i need to repeat few things which already said above.

    As above many people have mentioned that if you add a \u modifier it will work on Unicode character is TRUE and it is Working Perfectly in the example mentioned below

    http://ideone.com/750lMn

    Your examples which you have given in comments were not working because they don't have any white space characters between two sentences. And your code specifying it particularly that there must be a white space between sentences.

    \s+                 # Split on whitespace between sentences.
    

    The below example which you have in above comments is not working just because there is no space before Â.

    http://ideone.com/m164fp

提交回复
热议问题