Should this work in a Smart Rule that’s set up to alter custom metadata? It’s not working for me.
To be more detailed, here’s a set of (made-up) sample data that I’ve designed my regex to account for. As you can see, there are differences in the party names (the parts before and after the “v.”), and differences in the precise format of the citation (because they came come in different volumes of the case reporter, which is the first number; can come in different case reporters, which is the “U.S.” or “F.3d”; can start on different pages of a given reporter volume, which is the final number known as the “pincite”; can include information about the court - D.C. Cir., for example – or not; and are decided in different years):
United States v. Harris, 515 U.S. 12 (2004)
Thomas v. United States, 32 U.S. 535 (1999)
Jones v. Smith, 92 F.3d 1112 (D.C. Cir. 1991)
Here’s the regex I’ve written:
(?<Party1>((?=[A-Za-z])(.*?)(?=\sv.\s)))\sv.\s(?<Party2>((?=[A-Za-z])(.*?)(?=,\s[1-9]*[0-9]))),\s(?<Volume>([1-9]*[0-9]))\s(?<Reporter>([A-Z].[A-Z]*[A-Za-z0-9][.d]))\s(?<Pincite>([0-9]*[0-9]))\s((?<Court>(?<=()(.*?(?=[1-2][0-9][0-9][0-9])))(?<Year>([1-2][0-9][0-9][0-9]))
That seems to correctly capture all three of my examples above. Using the program Patterns to test these, here’s what I get:
But when I try to use a Smart Rule in DT to set custom metadata for those fields, I’m unable to get it to work. Here’s the Smart Rule I’ve set up:
The case name that produces for the Jones v. Smith example, for example, is just: ${Party1} v. ${Party2}
By contrast, if I set the Change Case Name field in the smart rule to \1 v. \4, it produces: Jones v. Smith
I.e., it labels it correctly. (I assume that \4 is returning Jones because there are so many subgroups within the regex. If I set the case name field to \1 v. \2, I get: Jones v. Jones )
For the case name, this isn’t a problem, because I can just use \1 v. \4 to set metadata. But \9 returns the “Reporter” field - i.e., the “F.3d” in this example - so I’m unable to get anything after that - the pincite, court, and year - into the metadata.
Apologies for hijacking an old thread with such a specific question, but I’d be thrilled to be pointed in the right direction on how to fix this. Thank you!