Here is a Java version... I know there are shortcut ways to specify "[a-zA-Z0-9]" and other character sets (ie the set of all ints, set of all lower case characters .... L* from formal language theory), but I was being lazy... and they'll probably be a bit different in C#.
Code:
public class RegexTest {
static String test1 = "http://www.site.com/attachment.php?attachmentid=12345";
static String test2 = "http://www.site.com/attachments/abc123foo/filename.jpg";
public static void test (String str, String rx) {
if (str.matches(rx))
System.out.println("str and rx match");
else
System.out.println("fail");
}
public static void main(String[] args) {
String r1 = "http://www\\.site\\.com/attachment\\.php\\?attachmentid=[0-9]+";
test(test1, r1);
String r2 = "http://www\\.site\\.com/attachments/[a-zA-Z0-9]+/[a-zA-Z0-9]+\\.(jpg|jpeg|gif|png)";
test(test2, r2);
System.exit(0);
}
}