分割字符串直到特定的子字符串 [英] Split the string till specific substring
本文介绍了分割字符串直到特定的子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一份参考书目,我必须将作者的名字与引文作者进行比较.我必须将字符串拆分到一年,这样我才能只获得作者姓名.但我不知道如何进一步进行.
例如:
I have a reference list, I have to compare author''s name with citation authors. I have to split the string till the year,So that I can get only author names. but I don''t have an idea how to proceed further.
For example:
txt="Sperrin, M., Jaki, T., & Wit, E. (2010). Probabilistic relabelling strategies for the label switching problem in Bayesian mixture models. Statistics in Computing, 20, 357-366."
-这是我必须从中提取作者姓名的文本
到目前为止,我已经尝试过了...
- This is the text from which I have to extract the author name
I have tried so far...
dim txt as string
dim txtarray() as string
txt="Sperrin, M., Jaki, T., & Wit, E. (2010). Probabilistic relabelling
strategies for the label switching problem in Bayesian mixture models.
Statistics in Computing, 20, 357-366."
txtarray=split(txt,",");
'here I have to split the string till year because it will split all the
'words which have comma with it.I need only the author's name.So, here I got
'struck how to get split string only till year.
'??????
推荐答案
每个条目的括号中都带有年份吗?尝试使用正则表达式,例如:
Every entry has year in parenthesis? Try regular expressions, for instance:
System.Text.RegularExpressions.Regex.Split(input, "\([12][0-9]{3}\)")
这篇关于分割字符串直到特定的子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文