开发者

regex for shortforms

开发者 https://www.devze.com 2022-12-30 11:09 出处:网络
I need a regex (JavaScript) which will extract shortforms from 开发者_Python百科a string for examplefrom below string

I need a regex (JavaScript) which will extract shortforms from 开发者_Python百科a string

for example from below string

Hibbs' essays in progress include "Anselm's Sacramental Imagination," "W.E.B. DuBois and Socratic Questioning," and "Everything That Rises Must Converge: Aquinas's Theological Re-formation of the Cardinal Virtues."

it will match "W.E.B." so the condition is it should have DOTs to seperate the letters

or from

Marcih J. Robert II. Distinguished Professor of Electrical & Computer Engineering. Ph.D. (1977) Texas Tech University, B.S./M.S. Rose-Hulman Institute of Technology (1972/1973).

Ph.D.    
B.S.     
M.S. 

will match

Thanks


This regex matches them but leaves line endings alone:

(\w+\.){2,}

(but also sub-strings like MSc., BSc. etc. will not be matched!)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号