I want to go through a scalar and every 35 character put a <br> in the string.
Id like to do this with a regex, but im not sure how..
any ideas?
Printable View
I want to go through a scalar and every 35 character put a <br> in the string.
Id like to do this with a regex, but im not sure how..
any ideas?
why with regexp?
what do you mean by scalar? a string?
- Which language? - some languages have functions which do this.
- Why regular expressions?
- What kind of characters do you want to match (if any). I.e. letters and numbers, any character, just numbers???
doesn't use reg exp thoughCode:str = "this is a very long string which will have br's stuck in it, possibly in wierd places but who gives a rat's arse about that little detail. Well, we'll see if this untested code will work, I sure hope so"
for (i=35;i<str.length;i=i+35)
{
str=str.substring(0,i)+"<br>"+str.substring(i+1,str.length)
}
document.write(str)
html =)
Found out how..
<div style="position:absolute;width:400"> Text here </div>
That will word wrap it without coding anything =-)