Splitting string containing letters and numbers not separated by any particular delimiter in PHP

后端 未结 2 629
太阳男子
太阳男子 2021-01-05 11:36

Currently I am developing a web application to fetch Twitter stream and trying to create a natural language processing by my own.

Since my data is from Twitter (lim

2条回答
  •  礼貌的吻别
    2021-01-05 12:01

    how about this:

    you extract numbers from string by using regexps, store them in an array, replace numbers in string with some kind of special character, which will 'hold' their position. and after parsing the string created only by your special chars and normal chars, you will feed your numbers from array to theirs reserved places.

    just an idea, but imho might work for you.

    EDIT: try to run this short code, hopefully you will see my point in the output. (this code doesnt work on codepad, dont know why)

提交回复
热议问题