如何使用函数或正则表达式从单元格中删除所有数字?
我的单元格如下所示,每行一个:
约翰·达菲:“遗产:文明” 和犹太人的-Fanfare & 合唱团、交响舞曲+管弦乐 套房。伯恩斯坦《小镇上的舞蹈》 剧集。皇家爱乐乐团/R.Williams
莉莲·伊格纳斯 1897-1963: 歌曲,1920-1935。安雅·范韦克 (Anja van Wijk) 弗兰斯·范鲁斯,钢琴
欣德米特,Trauermusik。珀塞尔《仙女》 大号床套房。罗西尼,第六弦乐奏鸣曲。 彼得罗夫芭蕾舞剧《创造世界》 套房。罗马尼亚民间舞蹈《巴托克》Sz 56. 塔蒂尼,G wAMaiorov 列宁格勒管弦乐团古代长笛协奏曲 &现代音乐/塞罗夫
比才、威尔第、马斯奈、普契尼:咏叹调 选自《卡门》、《弄臣》、《维特》、《玛侬》 莱斯科、托斯卡、图兰朵 + 歌曲 拉拉、迪卡普阿等人。彼得 布拉迪斯拉发男高音德沃尔斯基 Orch./Lenard 也表演《卡门》 公开的。 “泰国式”冥想。 录制现场,10/87
范蒂尼、劳赫、C.斯特劳斯、普留利、贝尔塔利: '宫廷节日弥撒 维也纳,1648' 约克郡巴赫合唱团和 巴洛克独奏家 + 巴洛克铜管乐 伦敦/西摩
达·芬奇,莱昂纳多1690-1730:咏叹调 塞米酰胺 Riconosciuta,迪酮 《阿班多纳塔》《十二人的卡杜塔》《洛》 切卡托·福佐、巴科节、卡托内 在尤蒂卡。玛丽亚·安吉利斯·彼得斯 sop。 wMCarraro 指挥
格鲁克、莫扎特、贝多芬、韦伯、威尔第、瓦格纳、庞基耶利、马斯卡尼、普契尼: 阿尔塞斯特的咏叹调,唐 乔瓦尼、费德里奥、奥布朗、巴洛、特里斯坦、瓦尔库尔、齐格弗里德、诸神黄昏、乔康达、卡瓦莱里亚、托斯卡。 海伦·维尔德布伦。建议1919-24
我想删除所有号码。我如何用公式做到这一点?或者也许只是搜索并用正则表达式替换?
I have cells that look like this, one per line:
Duffy,John: 'Heritage: Civilization
and the Jews'- Fanfare &
Chorale,Symphonic Dances + Orchestral
Suite. Bernstein,'On the Town' Dance
Episodes. Royal Phil./R.WilliamsLilien,Ignace 1897-1963:
Songs,1920-1935. Anja van Wijk,mezzo &
Frans van Ruth,pianoHindemith,Trauermusik. Purcell,'Fairy
Queen' Suite. Rossini,String Sonata 6.
Petrov,'Creation of the World' Ballet
Suite. Bartok,Romanian Folkdances Sz
56. Tartini,Flute Concerto in G w.A.Maiorov Leningrad Orch.for Ancient
& Modern Music/ SerovBizet,Verdi,Massenet,Puccini: Arias
from Carmen,Rigoletto,Werther,Manon
Lescaut,Tosca,Turandot + Songs by
Lara,Di Capua et al. Peter
Dvorsky,tenor w.Bratislava
Orch./Lenard Also performing 'Carmen'
Overt.& 'Thais' Meditation.
Rec.Live,10/87Fantini,Rauch,C.Straus,Priuli,Bertali:
'Festival Mass at the Imperial Court
of Vienna,1648' Yorkshire Bach Choir &
Baroque Soloists + Baroque Brass of
London/SeymourVinci,Leonardo1690-1730: Arias from
Semiramide Riconosciuta,Didone
Abbandonata,La Caduta dei Decemviri,Lo
Cecato Fauzo,La Festa de Bacco,Catone
in Utica. Maria Angeles Peters sop.
w.M.Carraro conductingGluck,Mozart,Beethoven,Weber,Verdi,Wagner,Ponchielli,Mascagni,Puccini:
Arias from Alceste,Don
Giovanni,Fidelio,Oberon,Ballo,Tristan,Walkure,Siegfried,Gotterdammerung,Gioconda,Cavalleria,Tosca.
Helene Wildbrunn. Rec.1919-24
I would like to remove ALL numbers. how do I do this with a formula? or maybe just search and replace with regex?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如何使用 VBA 执行此操作...
打开 Excel 工作簿并粘贴您提供的文本,如下所示:
选择这些行。
按“ALT+F11”打开 Visual Basic 编辑器。
转至“插入”菜单并打开一个模块。
输入此函数:
单击绿色的“播放”按钮来执行 VBA 脚本。
返回工作表并查看结果(不再有数字):
How to do that using VBA...
Open an Excel workbook and paste the text you provided this way:
Let those rows selected.
Press “ALT+F11” to open the Visual Basic Editor.
Go to the Insert Menu and open a Module.
Type in this function:
Click the green Play button to execute the VBA script.
Get back to the sheet and see the result (no more digits):
我遇到了类似的问题,但采取了另一种方式,想避免使用 vba。递归使用替代品对我来说很有效,如下所示:
原始数据(在 A1:An 中,n=整数)
股本回报率 -1.00
市盈率 0.07 -0.85
ROC-ROE 0.02 -0.03
等等..
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"0",""),"2",""),"2",""), "3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9 ","")
可以扩展以去掉“-”和小数点“.”。以及“+”(如果相关),最后使用
=trim(substitute(substitute(substitue(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1") ,""),"0",""),"2",""),"3",""),"4",""),"5",""),"6"," "),"7",""),"8",""),"9",""),"-",""),"+","")," .","") )
其中小写字母代表当前步骤中添加的复杂度。
通过更改对要解析的整个数组 (A1:An) 的范围引用并将公式作为数组输入(即使用 Ctl+Enter 而不是 Enter 来完成任务),这可以自然地映射到整个数组。
然后我使用 len(B1) 检查结果是否是我想要的。
诚然,不优雅。但这可能是教学生“即时”思考和编码的有用练习。
I was faced with a similar problem, but went another way, wanting to avoid using vba. A recursive use of substitute did the trick for me, as illustrated below:
Original data (in A1:An, n=integer)
ROE -1.00
P/E 0.07 -0.85
ROC-ROE 0.02 -0.03
etc..
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"0",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9","")
which can be extended to get rid of "-" and the decimal indicator "." as well as "+" (if relevant) and finally, superfluous spaces using
=trim(substitute(substitute(substitue(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"1",""),"0",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"-",""),"+","")," .",""))
where the lowercase represents complications added in the current step.
This maps naturally onto the entire array by changing the range reference to the entire array to be parsed (A1:An) and entering the formula as an array (i.e., using Ctl+Enter instead of Enter to complete the task).
I then use len(B1) to check the results are what I want.
Not elegant, admittedly. But may be a useful exercise for teaching students to think and code "on the fly."
更新:我不小心发布了包含函数而不是替换!
使用正则表达式进行搜索和替换效果很好,但您可能需要编辑后置文本(例如数字之前的逗号等)。
这是函数。模式很简单 =RegexReplace(cell, "\d", "")
UPDATED: I had accidentally posted a contains function instead of replace!
Search and replace with Regex works fine, but you might want to edit your text afterwords (like commas that were there before the numbers, etc.).
Here is the function. Pattern is simply =RegexReplace(cell, "\d", "")