Created
May 7, 2016 23:33
-
-
Save ltrzesniewski/90d4ddae88292bdb60c3620fb146b389 to your computer and use it in GitHub Desktop.
PCRE Unicode test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using PCRE; | |
using System; | |
using System.Linq; | |
namespace Temp | |
{ | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(PcreBuildInfo.Version); | |
Console.WriteLine(); | |
var patterns = new[] | |
{ | |
@"(Stake: £)(\d+(?:\.\d+)?)", | |
@"(winnings: £)(\d+(?:\.\d+)?)" | |
}; | |
var text = "Start Game, Credit: £200.00game num: 1, Stake: £2.00Spinning Reels:NINE SEVEN KINGKING STAR ACEQUEEN JACK KINGtotal winnings: £0.00End Game, Credit: £198Start..."; | |
foreach (var pattern in patterns) | |
{ | |
var re = new PcreRegex(pattern, PcreOptions.AutoCallout | PcreOptions.IgnoreCase | PcreOptions.MultiLine | PcreOptions.Unicode); | |
var calloutCount = 0; | |
re.Matches(text, 0, c => { | |
++calloutCount; | |
return PcreCalloutResult.Pass; | |
}).ToList(); | |
Console.WriteLine("{0} => {1}", pattern, calloutCount); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment