Problem:

之前在專案中, 有測到一個疑似一個 .NET Framework Regex 的 bug?

例如使用 PATTERN = “\w”

\w表示任何一個字元與數字以及 '_' ,意同 [a-zA-Z0-9_]

輸入全形英數字及中文字可以通過在 Server side 的 Regular expression 檢查

但相同的 pattern 在 Javascript 的 Regular expression 是不會過的

最近找到答案了…

Root Cause:

    Server side RegExp uses a different regular expression engine than JavaScript.

Solution:

    You can get compatible behavior by using a RegexOptions.EcmaScript with your Regex.

    Regex regexp = new Regex("\\w", RegexOptions.ECMAScript);

    For more information:

    RegexOptions 列舉型別

    http://msdn.microsoft.com/zh-tw/library/system.text.regularexpressions.regexoptions.aspx

    ECMAScript vs. Canonical Matching Behavior

    http://msdn.microsoft.com/en-us/library/04ses44d(VS.71).aspx

Sample:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RegExpApp._Default" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>

<!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 runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function testRegExp()
{
var email = document.getElementById("<%=txtEmail.ClientID %>").value;
var regexp = new RegExp("\\w");
if (email.match(regexp)) {
alert("Successful match");
} else {
alert("No match");
}
}
</script>


<script runat="server">
protected void btnNETRegExp_Click(object sender, EventArgs e)
{
Regex regexp;

if (chkECMAScript.Checked)
{
regexp = new Regex("\\w", RegexOptions.ECMAScript);
}
else
{
regexp = new Regex("\\w");
}

if(regexp.IsMatch(txtEmail.Text))
{
Response.Write("Successful match");
}
else{
Response.Write("No match");
}

}


</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnNETRegExp" runat="server" Text="NET RegExp" OnClick="btnNETRegExp_Click" />
&nbsp;&nbsp;&nbsp;
<asp:CheckBox ID="chkECMAScript" runat="server" />
<br />
<br />
<input id="btnJSRegExp" type="button" value="JavaScript RegExp" onclick="testRegExp();" /></div>
</form>
</body>
</html>

 

Hope this helps.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(58)

WOW. 這真是讓我驚呀的一則消息.

原文在:

http://www.microsoft.com/presspass/press/2009/nov09/11-09teamprisepr.mspx

為何驚呀? 因為微軟對於自家產品與其它廠牌的產品間的整合, 多半是透過 ISV 廠商來做.

這代表使用 Eclipse IDE 或使用 Unix, Linux and Mac OS X 平台的開發人員, 可以直接的使用 Microsoft Visual Studio Team Foundation Server 來建置他們的應用程式.

也意味著 TFS 真正可以更輕鬆的做到跨平台的支援.

筆者大膽預測, Visual Studio Lab Management 之後的版本也有可能做到跨平台的 Automation testing?

若真的可以, 那真是解決了目前專案中, 輕鬆實現在跨平台自動化測試的問題了.

Enjoy.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(124)

Facebook (書臉) SDK, 讓我們可以輕鬆的將 Facebook 應用程式與 ASP.NET, ASP.NET MVC, WinForms or Silverlight 整合在一起.

 

The toolkit is comprised of the following core assemblies:

  • Facebook.dll: This is the main assembly that will be used by all applications. This has all the logic to handle communication with the Facebook application. This assembly also has specific support of XAML applications (Silverlight and WPF) to enhance the Facebook platform to make databinding and data caching easier.
  • Facebook.Silverlight.dll: This is the Silverlight version of the main assembly that will be used by all Silverlight applications. This has all the logic to handle communication with the Facebook application. This assembly also has specific support of XAML applications to enhance the Facebook platform to make databinding and data caching easier. The REST API in this assembly is Asynchronous only.
  • Facebook.Web.dll: This assembly should be used by Canvas applications. The main functionality supported in this assembly is to encapsulate the handshake between the Facebook application and a canvas application (both FBML and IFrame)
  • Facebook.Web.Mvc.dll: Provide a support building canvas applications using ASP.NET MVC. Separated from Facebook.Web.dll to avoid all developers from needing to install the MVC bits.
  • Facebook.Winforms.dll: This assembly provides support for writing Facebook applications using Winform technology. This provides a Component that wraps the API to make it easier to use from Winforms. This also contains some user controls to help display Facebook data easily.

更多資訊:

http://msdn.microsoft.com/en-us/windows/ee388574.aspx

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(103)

今天想要把 CD 的 cda 檔案轉成 mp3 。一時間還不知如何做。

其實 Windows 內建的 windows media player 即可以把 cda 格式轉 mp3 格式。

步驟如下:
1. 開啟 windows media player
2. 開啟後,在檔案處按滑鼠右鍵選擇[工具] => [選項] => [擷取音樂],格式選擇 mp3,可以自行更改擷取轉換成 mp3 後的檔案位置。按確定。
3. 放入CD至工具列,選擇卻擷取檔案 => 打√ => 按 開始擷取,即開始轉換檔案。
4. 完成

Enjoy.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(110)

相信很多人都有使用 Windows 快速鍵的習慣,也就是用 Alt + Tab 來切換開啟的應用程式。
但若用在 Virutal Machine Connection 就失效了,網路上的善心人整理如下:

Windows Accelerator

Virtual Machine Connection Mapping

Description

Ctrl+Alt+Del

Ctrl+Alt+End

Switches to the security screen providing options to lock, switch user, change password, log off or run the Windows task manager.

Alt+Tab

Alt+Page Up

Switches between running desktop applications

Alt+Esc

Alt+Insert

Switches between running applications in launch order

Ctrl+Esc

Alt+Home

Invokes the Windows Start menu

None

Ctrl+Alt+Pause

Switch Virtual Machine Connection Tool to and from full screen mode

None

Ctrl+Alt+Left Arrow

Releases the mouse and keyboard focus from the Virtual Machine Connection Tool.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(46)

ISO 檔:

http://www.microsoft.com/downloads/details.aspx?FamilyID=dc333ac8-596d-41e3-ba6c-84264e761b81&displaylang=en

 

Web Bootstrapper:

http://www.microsoft.com/downloads/details.aspx?FamilyID=92c65d2d-0a6b-4507-a4dc-767f4cc6e823&displaylang=en

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(1) Hits(106)

http://www.microsoft.com/express/future/

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(2) Hits(108)

目前 Beta 2 在 October 19th, 2009 已釋出。

RTM 版預定在 March 22nd, 2010 釋出。

Enjoy.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(84)

從 Visual Studio 2005 開始,它已不是一個單純寫程式的工具,它包含了整個軟體開發過程中會使用到的功能。

Visual Studio 2010 分為為四個 Ultimate、Premium、Professional 和 Express(免費, free).

image

Enjoy.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(1) Hits(105)

VS 2010 的 Architecture tool 有提供七種圖形,筆者也因之前專案需要一些相關的圖,在煩惱之際,想到 VS 2010,在幾秒內,即可由 Visual studio 直接產生, 省去了很多時間,且產生完的圖也可以再修改,直是不錯用。

image

Windows 7 + Visual Studio 2010 Ultimate Beta 2.

Posted by anISV at 痞客邦 PIXNET Comments(0) Trackback(0) Hits(78)