Ruby on Rails
Monday, December 22, 2008
Insert Line break for word.
string.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,"\\1\\3\
")
Example : str ="kkkkkkkkkkk"
str.gsub(/(.{1,#{5}})( +|$\n?)|(.{1,#{5}})/,"\\1\\3\
")
o/p:
kkkkk
kkkkk
k
No comments:
Post a Comment
Newer Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment