user3568044
user3568044

Reputation: 163

Regular expression for matching letters followed by digits

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

Answers (1)

saurabh baid
saurabh baid

Reputation: 1877

Below regular expression will match all the samples which you have given.

(\S+\s*)+?(,|\()\s*(\d+)\)?

Upvotes: 1

Related Questions