寂寞的季节's profile冷色调的非情感-BlogPhotosBlogLists Tools Help
There are no music lists on this space.

冷色调的非情感-Blog

December 02

javascript在vs2003中调试随笔[转]

以前开发时很少用到javascript,现在由于项目需要得开始学习javascript

javascript的调试问题一直困扰我

有没有单步调试脚本的办法呢?

后经过人家指点,知道一简单方法随笔记录如下:

1。设置IE高级选项,把禁止调试去掉

2。让后打开你要调试的页面

3。回到vs2003中,选择工具-调试进程--选择explorer.exe--附加--选择script确定

4.选择debug-window-running document

这样就可以单步运行你的客户端脚本了

在Fitch and Mather 7.0项目中发现2个常用的javascript

1。页面启动时聚焦某一个文本框

  例如页面中有一个文本框

<asp:textbox id="b" runat="server">start</asp:textbox>

加入下面的脚本

function window_onload()

{

       if (document.all.b)

       {

              document.all.b.select();

              document.all.b.focus();

       }

}

  再添加

<body  onload="window_onload()">

  2。文本框内容改变时的互清除内容

例如页面中有2个文本框

<asp:textbox id="b" onpropertychange="OnEditHandler()" runat="server"></asp:textbox>

<asp:textbox id="a" onpropertychange="OnEditHandler()" runat="server"></asp:textbox>

var inHandler=false;                                                               

function OnEditHandler()

{

       if(inHandler)

               return;

        inHandler=true;

       var srcId = event.srcElement.id;               

                               

       if( srcId == "a" )

       {                  

          document.all.b.value = "";                  

       }

       else if( srcId == "b" )

       {                  

          document.all.a.value = "";                  

       }

         inHandler=false;

}

这样当a中内容改变时,就清空b中的文本,同样当b中内容改变时,就清空a中的文本

November 25

Asp.net 学习网站

名称:快速入门
地址:http://chs.gotdotnet.com/quickstart/
描述:本站点是微软.NET技术的快速入门网站,我们不必再安装.NET Framework中的快速入门示例程序,直接在网上查看此示例即看。


名称:微软官方.NET指导站点
地址:http://www.gotdotnet.com/
描述:上面的站点是本站的一个子站点,本站点提供微软.NET官方信息,并且有大量的用户源代码、控件下载,微软.NET开发组的人员也经常在此站点发表一些指导性文章。


名称:SourceForge
地址:http://www.sourceforge.net
描述:世界上最大的Open Source项目在线网站,上面已经有.NET的各种大型Open Source项目上千件,包括SharpDevelop、NDoc、Mono等都是在此站点发布最新源代码信息。


名称:CodeProject
地址:http://www.codeproject.com
描述:很多非官方的中小型示例源代及文章,相当全面,基本上我们想要的各种方面的资料都可以在此处查找。


名称:Fabrice's weblog
地址:http://dotnetweblogs.com/FMARGUERIE/Story/4139.aspx
描述:这是一个WebLog形式的在线日志网站,定期更新,包括.NET相关的工具、混淆器、反编译器等各种信息,十分值得收藏。


名称:
地址:http://www.aspalliance.com/aldotnet/examples/translate.aspx
描述:c#翻译为vb.net,提供一个文本框,将你的C#源代码贴进去,就可以帮你翻译成VB.NET语法。


名称:CSharpHelp
地址:http://www.csharphelp.com
描述: 专业的C#语言在线帮助网站,主要提供C#语言方面的技术文章。专业性很强。


名称:DotNet247
地址:http://www.dotnet247.com
描述:最好的索引网站,分别按照门类及命名空间的索引,也提供了Microsoft KB知识库。


名称:ASP.NET
地址:http://www.asp.net
描述:微软.NET webform的老巢,资料和实例代码都非常难得。


名称:微软.NET Winform
地址:http://www.windowsforms.net/
描述:微软.NET Winform的老巢。


名称:微软 KnowledgeBase
地址:http://support.microsoft.com/
描述:微软知识库,开发的时候遇到的怪问题,可能会在这里找到答案。


名称:MSDN
地址:http://msdn.microsoft.com/
描述:这个就不用多说了吧,虽然出了中文MSDN,但是资料还是不够全,英文的就什么都有了。


名称:HotScripts
地址:http://www.hotscripts.com/
描述:Welcome to HotScripts.com, the net’s largest PHP, CGI, Perl, javascript and ASP script collection and resource web portal. We currently have 24,004 scripts across 11 different programming languages and 1,240 categories, as well as links to books, articles, as well as programming tips and tutorials.


名称:ASPAlliance
地址:http://www.aspalliance.com/
描述:提供相当丰富的文章和示例代码,思路匮乏的时候可以找找思路


名称:CSDN文档中心
地址:http://dev.csdn.net/
描述:中文的,资料还算丰富,可以作为国内首选。


名称:DOTNET中华网
地址:http://www.aspxcn.com/
描述:2002-2003年的时候这个站点很不错的,不过现在好像管理不得力,有点疲软,资料更新也不过及时,论坛里人也不够热心了,因为希望它好起来,所以列出来。资料都比较老,不过有些D版的东西还可以。提供很多学习代码。


名称:中国DotNet俱乐部
地址:http://www.chinaspx.com/
描述:有点公司背景的网站,很健壮,资料更新及时,比较丰富。论坛解答也不错。


名称:【孟宪会之精彩世界】
地址:http://dotnet.aspx.cc/
描述:MS-MVP的个人站点,包括了他所有的经验文章,还是很值得一看的。


名称:dotNET Tools.org
地址:http://www.dotnettools.org
描述:ccboy,也就是CSDN的小气的神的站点,里面有很多关于.NET等的好东东。


名称:博客堂
地址:http://blog.joycode.com/
描述:半官方性质的MS-MVP汇集blog,大家可以在这里接触到最新的技术,了解发展趋势,对技术的探索等等,优秀的文章。


名称:DotNetBips.com - Applying .NET
地址:http://www.dotnetbips.com/
描述:该站点的文章,涉及到了整个.NET,从底层的IL到语言到架构,文章很多,质量还不错。


名称:C# Frequently Asked Questions
地址:http://blogs.msdn.com/csharpfaq/
描述:The C# team posts answers to common questions


名称:正则表达式
地址:http://www.regexplib.com/
描述:  正则表达式学习站点


名称:WINDOW formS FAQ
地址:http://www.syncfusion.com/FAQ/Winforms/
描述:常见的forms faq问题,很多问题都可以在这里找到答案。


名称:ASP.NET 常用类库说明
地址:http://www.123aspx.com/rotor/default.aspx
描述:不用多说,看标题就知道是关于asp.net的名称空间的


名称:ASP.NET System.Web.Mail
地址:http://www.systemwebmail.com/faq/3.8.aspx
描述:邮件发送常见问题解决方法


名称:VB.NET & C# 比较
地址:http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html
描述:VB.NET跟C#语法区别


名称:VB.NET架构师 BLOG
地址:http://panopticoncentral.net/
描述:不用多说,想了解VB.NET的朋友不可不去的站点(PS,不知道我有没有记错是不是这个地址)


名称:索克论坛
地址:http://www.sorke.com/bbs/Boards.asp
描述:我想应该是国内最好的第三方.NET控件的下载基地 
November 18

十进制转16进制 、十进制转二进制

#include "string.h"
#include
"stdio.h"
char *dectohex(int dec, int len
)
{
 
static char buf[256
];
 
char cell[] = "0123456789ABCDEF"
;
 
int i = 0
;
 
memset(buf, 0, 256
);
 
memset(buf, '0', len
);
 
while (dec != 0
)
  {
   
buf[i++] = cell[dec % 16
];
   
dec = dec / 16
;
  }
 
strcat(buf, "x0"
);
 
return (strrev(buf
));
}
char *dectobin(int dec, int len
)
{
 
int i = 0
;
 
static char buf[256
];
 
memset(buf, 0, 256
);
 
memset(buf, '0', len
);
 
while (dec != 0
)
  {
   
buf[i++] = dec % 2+48
;
   
dec = dec / 2
;
  }
 
return strrev(buf
);
}

November 11

How to call a Visual C# method asynchronously

How to call a Visual C# method asynchronously

Article ID : 315582
Last Review : January 18, 2006
Revision : 4.0
This article was previously published under Q315582

SUMMARY

The Microsoft .NET Framework makes it easy to call functions asynchronously. Calling functions asynchronously causes the system to execute them in the background on a secondary thread while the calling function continues to do other work. In a typical (synchronous) function call, the function is executed right away on the same thread that made the call. The calling function waits for the call to complete and receives the results of the call before continuing. By contrast, when you make an asynchronous call, you retrieve the results of the asynchronous call later. This article demonstrates how to do this by using Visual C#.
 

Requirements


The following list outlines the recommended hardware, software, network infrastructure, and service packs that are required:
Microsoft Windows 2000 or Microsoft Windows XP or Microsoft Windows Server 2003
Visual Studio .NET or Visual Studio 2005
This article assumes that you are familiar with the following topics:
Calling methods in Visual C#
How to use delegates
 

How To Make Asynchronous Calls

Asynchronous calls are made by using delegates. A delegate is an object that wraps a function. Delegates provide a synchronous function and also provide methods for calling the wrapped function asynchronously. Those methods are BeginInvoke() and EndInvoke(). The parameter lists of these methods vary depending on the signature of the function that the delegate wraps. Note that the Visual Studio .NET IntelliSense feature does not display BeginInvoke() and EndInvoke(), so you do not see them appear in the function lists as you type.

BeginInvoke() is used to initiate the asynchronous call. It has the same parameters as the wrapped function, plus two additional parameters that will be described later in this article. BeginInvoke() returns immediately and does not wait for the asynchronous call to complete. BeginInvoke() returns an IAsyncResult object.

The EndInvoke() function is used to retrieve the results of the asynchronous call. It can be called anytime after BeginInvoke(). If the asynchronous call has not completed yet, EndInvoke() blocks until it completes. The parameters of the EndInvoke() function includes the out and ref parameters that the wrapped function has, plus the IAsyncResult object that is returned by BeginInvoke().

The following is an example of a delegate and its BeginInvoke() and EndInvoke() methods:
// The following delegate 
delegate string MethodDelegate(int iCallTime, out int iExecThread)  ;

// will have the following BeginInvoke() and EndInvoke methods:
IAsyncResult MethodDelegate.BeginInvoke(int iCallTime, out int iExecThread, AsyncCallback cb, object AsyncState); 

string MethodDelegate.EndInvoke (out int iExecThread, IAsyncResult ar) ;
    
There are four common ways to use BeginInvoke() and EndInvoke() to make asynchronous calls. After you call BeginInvoke(), you can:
Optionally do some other work and then use EndInvoke().
Obtain a WaitHandle that is provided by the IAsyncResult object, use its WaitOne method to block until the WaitHandle is signaled, and then call EndInvoke().
Poll the IAsyncResult object to determine when the asynchronous call has completed, and then call EndInvoke().
Have the system call a callback function that you specify. This callback function calls EndInvoke() and processes the results of the asynchronous call when it completes.
The following code samples demonstrate these call patterns and contrast them with making a synchronous call by using the following function:
string LongRunningMethod (int iCallTime, out int iExecThread)
{
 Thread.Sleep (iCallTime) ;
 iExecThread = AppDomain.GetCurrentThreadId ();
 return "MyCallTime was " + iCallTime.ToString() ;
}

    
LongRunningMethod() simulates a function that runs for long time by sleeping. It returns the sleep time and the ID of the thread that executes it. If you call it asynchronously, you find that the thread ID of the executing thread is different from that of the calling thread.

The first step is to define the delegate that wraps the function:
delegate string MethodDelegate(int iCallTime, out int iExecThread)  ;
    

Sample 1: Calling A Method Synchronously

This sample demonstrates how to call LongRunningMethod() synchronously by using a MethodDelegate delegate. The other samples contrast this by making calls asynchronously.
1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
2. Create a new Visual C# Console Application project named AsyncDemo.
3. Add a class named AsyncDemo that is defined as follows to the project in a new .cs file:
using System;
using System.Threading ; 
using System.Windows.Forms ;

public class AsyncDemo
{
 string LongRunningMethod (int iCallTime, out int iExecThread)
 {
  Thread.Sleep (iCallTime) ;
  iExecThread = AppDomain.GetCurrentThreadId ();
  return "MyCallTime was " + iCallTime.ToString() ;
 }

 delegate string MethodDelegate(int iCallTime, out int iExecThread)  ;

 public void DemoSyncCall()
 {
  string s ;
  int iExecThread;

  // Create an instance of a delegate that wraps LongRunningMethod.
  MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;  
   
  // Call LongRunningMethod using the delegate.
  s = dlgt(3000, out iExecThread);  
   
  MessageBox.Show (string.Format ("The delegate call returned the string:   \"{0}\", 
                                        and the thread ID {1}", s, iExecThread.ToString() ) );
 }
}
     
Later, this class demonstrates how to make asynchronous calls. Initially, however, it only contains the DemoSyncCall() method, which demonstrates how to call the delegate synchronously.
4. Add the following code in the body of the Main function that Visual Studio automatically creates in your project:
static void Main(string[] args)
{
 AsyncDemo ad = new AsyncDemo () ;
 ad.DemoSyncCall() ;
}
     
5. Press CTRL+F5 to run your application.
 

Sample 2: Calling A Method Asynchronously by Using the EndInvoke() Call Pattern

In this section, the sample invokes the same method asynchronously. The call pattern that is used is to call BeginInvoke, do some work on the main thread, and then call EndInvoke(). Note that EndInvoke() does not return until the asynchronous call has completed. This call pattern is useful when you want to have the calling thread do work at the same time that the asynchronous call is executing. Having work occur at the same time can improve the performance of many applications. Common tasks to run asynchronously in this way are file or network operations.
1. Add a method named DemoEndInvoke() to the AsyncDemo class. The DemoEndInvoke function demonstrates how to call the delegate asynchronously.
public void DemoEndInvoke()
{
 MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;
 string s ;
 int iExecThread;

 // Initiate the asynchronous call.
 IAsyncResult ar = dlgt.BeginInvoke(3000, out iExecThread, null, null);  

 // Do some useful work here. This would be work you want to have
 // run at the same time as the asynchronous call.

 // Retrieve the results of the asynchronous call.
 s = dlgt.EndInvoke (out iExecThread, ar) ;  

 MessageBox.Show (string.Format ("The delegate call returned the string:   \"{0}\", 
                               and the number {1}", s, iExecThread.ToString() ) );
}
     
2. Edit the source code for Main so that it contains the following code:
static void Main(string[] args)
{
 AsyncDemo ad = new AsyncDemo () ;
 ad.DemoEndInvoke() ;
}
     
3. Press CTRL+F5 to run your application.
 

Sample 3: Calling A Method Asynchronously And Using A WaitHandle To Wait For The Call To Complete


In this section, the sample calls the method asynchronously and waits for a WaitHandle before it calls EndInvoke(). The IAsyncResult that is returned by BeginInvoke() has an AsyncWaitHandle property. This property returns a WaitHandle that is signaled when the asynchronous call completes. Waiting on a WaitHandle is a common thread synchronization technique. The calling thread waits on the WaitHandle by using the WaitOne() method of the WaitHandle. WaitOne() blocks until the WaitHandle is signaled. When WaitOne() returns, you can do some additional work before you call EndInvoke(). As in the previous sample, this technique is useful for executing file or network operations that would otherwise block the calling main thread.
1. Add a function named DemoWaitHandle() to the AsyncDemo class. The DemoWaitHandle() function demonstrates how to call the delegate asynchronously.
public void DemoWaitHandle ()
{
 string s ;
 int iExecThread;

 MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;

 // Initiate the asynchronous call.
 IAsyncResult ar = dlgt.BeginInvoke(3000, out iExecThread, null, null); 

 // Do some useful work here. This would be work you want to have
 // run at the same time as the asynchronous call.

 // Wait for the WaitHandle to become signaled.
 ar.AsyncWaitHandle.WaitOne() ;

 // Get the results of the asynchronous call.
 s = dlgt.EndInvoke (out iExecThread, ar) ;
   
 MessageBox.Show (string.Format ("The delegate call returned the string:   \"{0}\", 
                                 and the number {1}", s, iExecThread.ToString() ) );
}
     
2. Edit the source code for Main so that it contains the following code:
static void Main(string[] args)
{
 AsyncDemo ad = new AsyncDemo () ;
 ad.DemoWaitHandle () ;
}
     
3. Press CTRL+F5 to run your application.
 

Sample 4: Calling A Method Asynchronously by Using the Polling Call Pattern

In this section, the sample polls the IAsyncResult object to find out when the asynchronous call has completed. The IAsyncResult object that is returned by BeginInvoke() has an IsCompleted property that returns True after the asynchronous call completes. You can then call EndInvoke(). This call pattern is useful if your application does ongoing work that you do not want to have blocked by a long-running function call. A Microsoft Windows application is an example of this. The main thread of the Windows application can continue to handle user input while an asynchronous call executes. It can periodically check IsCompleted to see if the call has completed. It calls EndInvoke when IsCompleted returns True. Because EndInvoke() blocks until the asynchronous operation is complete, the application does not call it until it knows that the operation is complete.
1. Add a function named DemoPolling() to the AsyncDemo class. The DemoPolling() function demonstrates how to call the delegate asynchronously and use polling to see if the process is complete.
public void DemoPolling()
{
 MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;
 string s ;
 int iExecThread;

 // Initiate the asynchronous call.
 IAsyncResult ar = dlgt.BeginInvoke(3000, out iExecThread, null, null); 

 // Poll IAsyncResult.IsCompleted
 while(ar.IsCompleted == false)
 {
  Thread.Sleep (10) ;  // pretend to so some useful work
 }
 s = dlgt.EndInvoke (out iExecThread, ar) ;

 MessageBox.Show (string.Format ("The delegate call returned the string:   \"{0}\", 
                                and the number {1}", s, iExecThread.ToString() ) );
}

     
2. Edit the source code for Main. Replace the content of the function with the following code:
static void Main(string[] args)
{
 AsyncDemo ad = new AsyncDemo () ;
 ad.DemoPolling () ;
}
     
3. Press CTRL+F5 to run your application.
 

Sample 5: Executing a Callback When an Asynchronous Method Completes

In this section, the sample provides a callback delegate to the BeginInvoke() function that the system executes when the asynchronous call completes. The callback calls EndInvoke() and processes the results of the asynchronous call. This call pattern is useful if the thread that initiates the asynchronous call does not need to process the results of the call. The system invokes the callback on a thread other than the initiating thread when the asynchronous call completes.

To use this call pattern, you must pass a delegate of type AsyncCallback as the second-to-last parameter of the BeginInvoke() function. BeginInvoke() also has a final parameter of type object into which you can pass any object. This object is available to your callback function when it is invoked. One important use for this parameter is to pass the delegate that is used to initiate the call. The callback function can then use the EndInvoke() function of that delegate to complete the call. This call pattern is demonstrated below.
1. Add a two methods named DemoCallback() and MyAsyncCallback() to the AsyncDemo class. The DemoCallback() method demonstrates how to call the delegate asynchronously. It uses a delegate to wrap the MyAsyncCallback() method, which the system calls when the asynchronous operation completes. MyAsyncCallback() calls EndInvoke().
public void DemoCallback()
{
 MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;
 string s ;
 int iExecThread;

 // Create the callback delegate.
 AsyncCallback cb = new AsyncCallback(MyAsyncCallback);

 // Initiate the Asynchronous call passing in the callback delegate
 // and the delegate object used to initiate the call.
 IAsyncResult ar = dlgt.BeginInvoke(3000, out iExecThread, cb, dlgt); 
}

public void MyAsyncCallback(IAsyncResult ar)
{
 string s ;
 int iExecThread ;

 // Because you passed your original delegate in the asyncState parameter
 // of the Begin call, you can get it back here to complete the call.
 MethodDelegate dlgt = (MethodDelegate) ar.AsyncState;

 // Complete the call.
 s = dlgt.EndInvoke (out iExecThread, ar) ;

 MessageBox.Show (string.Format ("The delegate call returned the string:   \"{0}\", 
                                and the number {1}", s, iExecThread.ToString() ) );
}

     
2. Edit the source code for Main. Replace the content of the function with the following code:
static void Main(string[] args)
{
 AsyncDemo ad = new AsyncDemo () ;
 ad.DemoCallback() ;
}
     
3. Press CTRL+F5 to run your application.

AppDomain和Assembly动态装载、卸载DLL

try
{
//取得类名
string PortOrClass=(string)CfgRow["PortOrClass"];
//创建 AppDomainSetup 对象
AppDomainSetup setup = new AppDomainSetup();
//
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
//新域的 config 和本域公用一个
setup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
//安全级别相同
Evidence adevidence = AppDomain.CurrentDomain.Evidence;
//创建新的子,应用程序[域]
aDoc = AppDomain.CreateDomain(PortOrClass,adevidence,setup);


//用新的域动态加载,dll(dllpath 是完全路径)
//动态加载的类必须继承 MarshalByRefObject 要不就是有 out ref 参数的必须,自己试验吧
object o = aDoc.CreateInstanceFromAndUnwrap(dllpath,PortOrClass);
//转换为 ILibService 接口(这是一个接口)
ilibService =(ILibService)o;
//调用函数
ilibService.ServiceExec(inParams,out outParams,acc,AppPath);


}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放
if (ilibService !=null)
{
ilibService.Dispose();
}
//卸载域,加载的dll也会被释放
if (aDoc !=null)
{
AppDomain.Unload(aDoc);

}

}
October 25

怎么感觉朋友越来越少了

  不知不觉的电话少了,短信少了,QQ也不在跳跃,一切都很安静,不知道是自己把自己给锁起来了 还是正在被外界所排斥.
  感觉自责感越来越重,有种说不出的味道!
  人与人之间到底是个什么关系,是自己来界定,还是通过世俗连接!
 
October 09

常用正则表达式

常用正则表达式

  正则表达式用于字符串处理、表单验证等场合,实用高效。现将一些常用的表达式收集于此,以备不时之需。

匹配中文字符的正则表达式: [\u4e00-\u9fa5]
评注:匹配中文还真是个头疼的事,有了这个表达式就好办了

匹配双字节字符(包括汉字在内):[^\x00-\xff]
评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)

匹配空白行的正则表达式:\n\s*\r
评注:可以用来删除空白行

匹配HTML标记的正则表达式:<(\S*?)[^>]*>.*?</\1>|<.*? />
评注:网上流传的版本太糟糕,上面这个也仅仅能匹配部分,对于复杂的嵌套标记依旧无能为力

匹配首尾空白字符的正则表达式:^\s*|\s*$
评注:可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式

匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
评注:表单验证时很实用

匹配网址URL的正则表达式:[a-zA-z]+://[^\s]*
评注:网上流传的版本功能很有限,上面这个基本可以满足需求

匹配帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
评注:表单验证时很实用

匹配国内电话号码:\d{3}-\d{8}|\d{4}-\d{7}
评注:匹配形式如 0511-4405222 或 021-87888822

匹配腾讯QQ号:[1-9][0-9]{4,}
评注:腾讯QQ号从10000开始

匹配中国邮政编码:[1-9]\d{5}(?!\d)
评注:中国邮政编码为6位数字

匹配身份证:\d{15}|\d{18}
评注:中国的身份证为15位或18位

匹配ip地址:\d+\.\d+\.\d+\.\d+
评注:提取ip地址时有用

匹配特定数字:
^[1-9]\d*$    //匹配正整数
^-[1-9]\d*$   //匹配负整数
^-?[1-9]\d*$   //匹配整数
^[1-9]\d*|0$  //匹配非负整数(正整数 + 0)
^-[1-9]\d*|0$   //匹配非正整数(负整数 + 0)
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$   //匹配正浮点数
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$  //匹配负浮点数
^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$  //匹配浮点数
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$   //匹配非负浮点数(正浮点数 + 0)
^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$  //匹配非正浮点数(负浮点数 + 0)
评注:处理大量数据时有用,具体应用时注意修正

匹配特定字符串:
^[A-Za-z]+$  //匹配由26个英文字母组成的字符串
^[A-Z]+$  //匹配由26个英文字母的大写组成的字符串
^[a-z]+$  //匹配由26个英文字母的小写组成的字符串
^[A-Za-z0-9]+$  //匹配由数字和26个英文字母组成的字符串
^\w+$  //匹配由数字、26个英文字母或者下划线组成的字符串
评注:最基本也是最常用的一些表达式

原载地址:http://lifesinger.3322.org/myblog/?p=185

 

寂寞的季节 雲

Occupation
Location
雪无踪,情无终!雪无形,情有影~~
冬来,雪轻盈!爱来,情倾城~~
冬过,雪化水!爱依然,情始终~~
There are no photo albums.