将备用逗号更改为半冒号... [英] Change alternate commas to semi colons...
问题描述
有一系列作者,如:
Carson,David,Milne,Rebecca,Pakes,Francis J.,Shalev,Karen,
Shawyer ,Andrea
我想编写一个函数来将每个其他逗号更改为
半冒号(从而定义一个名称的结束位置和下一个名称的开头) 。
我可以通过写一个复杂的(和慢的)程序来做到这一点 - 但是有没有
a使用正则表达式的快速方法呢?
非常感谢。
St *********** @ gmail.com 写道:With一系列作者如:
Carson,David,Milne,Rebecca,Pakes,Francis J.,Shalev,Karen,
Shawyer,Andrea
我会喜欢编写一个函数来将每个其他逗号更改为一个半冒号(从而定义一个名称的结束位置和下一个名称的开头)。
我可以通过编写一个复杂(和缓慢)的过程来做到这一点 - 但是有没有
快速使用正则表达式来做到这一点?
非常感谢。
为什么不使用str_replace()内在函数?
str =" Carson,David,Milne,Rebecca, Pakes,Francis J.,Shalev,
Karen,Shawyer,Andrea" ;;
str = str_replace(","," ;",
With a string of authors such as:
Carson, David, Milne, Rebecca, Pakes, Francis J., Shalev, Karen,
Shawyer, Andrea
I would like to write a function to change every other comma into a
semi colon (thereby defining where one name ends and the next begins).
I could do it by writing a complex (and slow) procedure - but is there
a quick way of doing it using regular expressions, for example?
Many thanks.
St***********@gmail.com wrote:With a string of authors such as:
Carson, David, Milne, Rebecca, Pakes, Francis J., Shalev, Karen,
Shawyer, Andrea
I would like to write a function to change every other comma into a
semi colon (thereby defining where one name ends and the next begins).
I could do it by writing a complex (and slow) procedure - but is there
a quick way of doing it using regular expressions, for example?
Many thanks.
Why not just use str_replace() intrinsic function?
str = "Carson, David, Milne, Rebecca, Pakes, Francis J., Shalev,
Karen, Shawyer, Andrea";
str = str_replace(",", ";",
这篇关于将备用逗号更改为半冒号...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!