I'm having some trouble getting this regular expression to work. I need R1 to match s1 ONLY and R2 to match s2 ONLY. No matter what I do though, R1 matches s2. Here is basicly what I think it should be but I've tried tons over other things. No dice.
static void Main(string args)
Regex R1 = new Regex(@"You partially hit (.+?)(?!.*with.*)for (\d*,?\d+) points of (.+) damage\.");
Regex R2 = new Regex(@"You partially hit (.+) with (.+) for (\d*,?\d+) points of (.+) damage\.");
string s1 = "You partially hit Roryk for 37 points of Shadow damage.";
string s2 = "You partially hit Pongsakorn with Pounce for 99 points of Shadow damage.";
Got. Needed to use ?<! which I believe is negative lookbehind, the chart that I was following had it listed as the same as ?!= which I tested instead cause I was loading these from an XML file, where the < is not so friendly.
If this is already resolved please use the threadtools and sign it as resolved Thx
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ? My latest articles : Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7