This is related to my previous question over here.
(replace-regexp "\\(\\[\\[\\)\\(zotero:.+\\]\\)\\(\\[.+,[《〈][^《〈]+[》〉]\\)?.+。\\(\\]\\]\\)" "\\1cite-\\2\\3\\4,頁")
I'd like to use the above code to shorten Chinese citation strings to author,title,page
format.
Sample Data
Original String:
[[zotero://select/items/1_P36Y9V2B][周東平,〈《晉書·刑法志》校注舉隅〉,《中國古代法律文獻研究》,2016年,00期。]]
Expected Result (shortened string):
[[cite-zotero://select/items/1_P36Y9V2B][周東平,〈《晉書·刑法志》校注舉隅〉]],頁
The code snippet [《〈][^《]+[》〉]
correctly restricts the search to a single title element between ,
s.
When joined with .+,
, however, it fails to be non-greedy and ends up picking up both article title (between 〈〉
s) and journal title (between 《》
s) at the same time.
This results in a shortened citation which is lengthier than expected.
[[cite-zotero://select/items/1_P36Y9V2B][周東平,〈《晉書·刑法志》校注舉隅〉,《中國古代法律文獻研究》]],頁
How do we make \\3
non-greedy, as expected?
Update:
I just realize this could be an issue specific to the data string listed above, i.e.:
周東平,〈《晉書·刑法志》校注舉隅〉,《中國古代法律文獻研究》,2016年,00期。
Somehow, the 《晉書·刑法志》
nested in 《晉書·刑法志》校注舉隅〉
complicated matters.
Other simpler, but similarly structured data such as this worked as expected:
[[zotero://select/items/1_97XVI66Q][金春峯,〈周官之社會行政組織〉,收入《周官之成書及其反映的文化與時代新考》台北:東大,1993年。]]
Result:
[[cite-zotero://select/items/1_97XVI66Q][金春峯,〈周官之社會行政組織〉]],頁