获取2个分隔符之间的第n个文本字符串 [英] Get the nth string of text between 2 separator characters

查看:104
本文介绍了获取2个分隔符之间的第n个文本字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一长串由字符(竖线字符)分隔的文本.我需要在第3个管道和第4个管道之间获取文本.不知道该怎么做...

I have a long string of text delimited by a character (pipe character). I need to get the text between the 3rd and 4th pipes. Not sure how to go about this...

对正则表达式或非正则表达式开放,以效率最高的那个为准.如果不存在可以传递的扩展方法,则特别开放:

Open to regex or non-regex, whichever is the most efficient. Especially open to extension method if none exist to be able to pass in:

  • seperatorChar
  • 索引

推荐答案

如果

string textBetween3rdAnd4thPipe = "zero|one|two|three|four".Split('|')[3];

不执行您的意思,您需要更详细地说明.

doesn't do what you mean, you need to explain in more detail.

这篇关于获取2个分隔符之间的第n个文本字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆