I'm a new in PHP and .NET. Here is my question. I write the same Regular Expression in PHP and .NET. But I don't know why their countRow are different answers. I want their outputs are the same(countRow = 1). Please help me solve this problem. Thank a lot.
This is my PHP code.
<?php
$p = "S:";
$pattern = "/^([A-Z]:+)$/";
$countRow = 0;
if(preg_match($pattern,$p)){
$countRow = $countRow + 1;
}
echo $countRow;
//countRow is 1;
?>
This is my C#.NET code.
using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
int countRow = 0;
string p= "S:";
string pattern = @"/^([A-Z]:+)$/";
if(Regex.IsMatch(p,pattern)){
countRow = countRow + 1;
}
Console.WriteLine("{0}",countRow);
//countRow is 0
}
}