Reputation: 163
I have to match the citations within a document. The citations can be of the forms: Author names, year; Author names(year); (Author names,year) For example: 'James et al., 2010', 'James & Juda, 2010', 'James & Juda(2010)','(James & Juda, 2010)'. I have tried:
[A-Za-z]+[0-9]{4}
and
(([A-Z]([A-Za-z][&.,])+\d{4})
One or more occurrences of characters followed by some punctuations and then 4 digits( specifying year) is what I meant. But its not working. Please help me with this regard.
Upvotes: 1
Views: 1219
Reputation: 1877
Below regular expression will match all the samples which you have given.
(\S+\s*)+?(,|\()\s*(\d+)\)?
Upvotes: 1