很抱歉昨天的问题. 有一个名为"something.docx"的字符串.如何使用正则表达式拆分字符串. 还可以找到如何修改".docx"扩展名,即如何用".pdf"替换它. 如何查找字符串的反义,意味着在"something.docx"中,您可能会从头开始,找到第一个.(点),然后将字符串拆分成那个.(dot),并捕获前面的字符串,意味着"something"并添加".pdf"扩展名. 注意:您将"something.docx"视为字符串,而不是文档,并且也不会转换为pdf格式.只需将.docx替换为.pdf
sry for yesterday''s question.. There is a string named as "something.docx". How to split that string using Regular Expression. Also find how modify the ".docx" extension,means how it can be replace with ".pdf". How to find the reverse of string, means In "something.docx", you may come from back onwards, and find the first .(dot) and split the string upto that .(dot) and capture the front string means "something" and add ".pdf" extensions. Note: You consider "something.docx" as a string, not a document and also its not converted into pdf format. just replace .docx with .pdf
推荐答案本文 [ ^ ]可以让您简要了解功能强大的正则表达式以及如何使用它们拆分字符串. This article[^] would give you a brief idea of how powerful regular expressions can be and how they could be used to split strings.
您在这里不需要正则表达式. 查看类System.IO.Path. System.IO.Path.ChangeExtension和System.IO.Path.GetExtension,System.IO.Path.GetFileName和System.IO.Path.GetFileNameWithoutExtension怎么样?它将满足您的所有需求.参见: msdn.microsoft/en-us/library/system.io. path.aspx [^ ]. 毕竟,您有string.Split. 最后的提示:没有操纵"字符串-它们是不可变的.所有方法仅读取字符串数据并从头开始创建其他数据.实际上,出于性能和其他原因,这是一个很好的了解.
更多推荐
使用正则表达式的字符串操作
发布评论