c# - Limit of characters in string -
i have textbox takes string. string long. want limit displayed text (for example 10 characters) , attach 3 dots like:
if text box takes value "to be, or not be, question:" display "to be, or..."
or
if text box takes value "to be" display "to be"
html.devexpress().textbox( tbsettings => { tbsettings.name = "tbnameedit";; tbsettings.width = 400; tbsettings.properties.displayformatstring=??? }).bind(databinder.eval(product, "reportname")).gethtml();
if need use regex, can this:
regex.replace(input, "(?<=^.{10}).*", "..."); this replaces text after tenth character 3 dots.
the (?<=expr) lookbehind. means expr must matched (but not consumed) in order rest of match successful. if there fewer ten characters in input, no replacement performed.
here demo on ideone.
Comments
Post a Comment