Skip to content

Instantly share code, notes, and snippets.

@ltrzesniewski
Created May 7, 2016 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltrzesniewski/90d4ddae88292bdb60c3620fb146b389 to your computer and use it in GitHub Desktop.
Save ltrzesniewski/90d4ddae88292bdb60c3620fb146b389 to your computer and use it in GitHub Desktop.
PCRE Unicode test
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