简体   繁体   English

如何将长字分割成字?

[英]How to split long word into words?

I have a long word, for example: 我说的很长,例如:

welcometostackoverflow

or 要么

betweenparagraphs

How to get string or array like this in PHP? 如何在PHP中获得像这样的字符串或数组?

Welcome to Stack Overflow

or 要么

between paragraphs

Sample results: http://www.bing.com/images/search?q=betweenparagraphs&go=&qs=n&sk=&form=QBIR 示例结果: http : //www.bing.com/images/search?q= betweenparagraphs&go=& qs=n&sk=&form=QBIR

It's pretty much impossible since your code cannot know where a word ends. 由于您的代码无法知道单词的结尾,因此几乎是不可能的。 Even with a dictionary there would be ambiguous situations. 即使有了字典,情况也仍然模棱两可。

Simply.. You can't do that not even with large collection of sample words in an array or a file or something else. 很简单..即使数组,文件或其他内容中包含大量示例单词,您也无法做到这一点。

Reasons are: 原因如下:

  1. Your input string as i thought will not be welcometostackoverflow everytime. 我认为您的输入字符串不会每次都欢迎到stackoverflow
  2. It will cause ambiguous situation in large no. 大号会造成模棱两可的情况。 of cases. 的情况。

    for example : overflow : it may be over or flow or overflow or low .. 例如:溢出:它可以是overflowoverflowlow ..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM