开发者

Adjusting String length

开发者 https://www.devze.com 2023-04-06 04:19 出处:网络
I have a DIV with fixed height and the text what i can echo here is of max 100 Characters. But what I get is Dynamic text. This开发者_高级运维 can also cantain 500 Characters.

I have a DIV with fixed height and the text what i can echo here is of max 100 Characters. But what I get is Dynamic text. This开发者_高级运维 can also cantain 500 Characters.

And this text may also contain html tags.

Now I can simply take the first 100 Characters, as it can cut the tag. Like

<string> Sample Text Here</st ...

And this will make the contents of the complete website BOLD.

Which will a better way to do this?


It sounds like you want to strip the HTML tags and then trim to the first 100 characters:

#left(reReplace(variables.inputString,'<[^>]+>','','ALL'), 100)#


May be like this.

<cfset strWithoutTag = rereplace(strWithTag,"<[\/]*\w+[^>]*>","","all")>
<cfdump var="#strWithoutTag#">
<cfset truncStr = left(strWithoutTag,100)>
<cfdump var="#truncStr#">
0

精彩评论

暂无评论...
验证码 换一张
取 消