Sunday 15 April 2012

javascript - Regex to split string into verying size chunks -


I am trying to break a string into different size segments, such as the word "wave" like:

  Cat sitting on a mat of cat is sitting on a mat on a mat.  

As the length of words is different, I separate it I want the closest location

I am trying to do a lot more than one line. Although I do not like the idea of ​​loop I have started with it:

  / {5} \ w * / g  

I have tried to add around () and {} but Reggae can not get hanged. Is it possible to do this? Or will it involve some types of loops?

I think that there is something like a Regex, but a lot depends on the input string. Apart from this, you have to think about how to arrange fragmentation, whether to trim or not, how to pad, etc. So there will not be only one regedge.

This Reggae Pattern: ((?: [^ \ S] + (?: \ S | $)) {1,20}) Whatever you do in the following string Searches can generate something similar to that: Sitting on the cat mat on a cat mat cat works on the mat. This works due to the extra space, where the right breaks happen.

  The cat was sitting on the mat, sitting on the cat mat sitting on the mat. See  


No comments:

Post a Comment