字符串截取(包括html,BasicPage.cs类使用)
/// <summary>
/// 截断字符串(中文计一个字符宽度,其它计半个字符宽度)
/// </summary>
/// <param name="input">需截断的字符串</param>
/// <param name="length">字符宽度</param>
/// <returns>截断字符串(带"...")</returns>
protected string truncatedChars(string input, int length)
{
input = Server.HtmlEncode(input);
if (input.Length > length)
{
int pos = 0;
string result = "";
foreach (char chr in input)
{
if (Regex.IsMatch(chr.ToString(), "[^\x00-\xff]"))
{
pos += 2;
}
else
{
pos += 1;
}
result += chr.To
相关文档:
using System.Text.RegularExpressions; //引入的命名空间
以下为引用的内容:
//清除HTML函数
public static string NoHTML(string Htmlstring)
{
//删除脚本
Htmlstr ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
Go
----截取字符串,并出去html
create FUNCTION [dbo].[CutString] (@str varchar(1000),@length int)
RETURNS varchar(1000) AS
BEGIN
declare @mainstr varchar(1000)
declare @substr varchar(1000)
if(@str is not null or @st ......
<@Aattention Content="本Blog原创文章,转载或引用请注明转载"
from="Robby.cnblogs.com"@>
由于自己的搜索引擎中做到了这一块内容,所以今天说说如何抓取网页数据、分析并且去除Html标签,给大家提供一个参考。我的平台是Visual
Studio2005,C#。
& ......
到底元素的id和name有什么区别阿?为什么有了id还要有name呢?!
id的主要用途:
在客户端页面作为对象的唯一表示,同一个页面中不允许出现多个相同的id.可以使用javascript的document.getElementById('id')来获取对象.
name的具体用途有:
用途1:
作为可与服务器交互数据的HTML元素的服务器端的标示,比如input、sele ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>文本编辑器</title>
<meta http-equiv="C ......