将两个类似标识符C#之间的修剪文本
我有一个字符串
string myString = "NotNeeded/ThisTextIsNeeded/NotNeeded";
,我只需要“ thisTextisneed ”,而开始和结束标识符是相同的“/” 。我可以使用子字符串,但为此我需要不同的标识符。任何人都可以使用C#中的类似标识符引导我如何做到这一点。
编辑:不一定是“ noted/thisTextisneed/notneded ”。也可以更改它,例如“ abc/thisTextisneed/abc ”或“ aaa/apppp/abc ”。我只需要/和/之间的任何文本。
谢谢
I have a string
string myString = "NotNeeded/ThisTextIsNeeded/NotNeeded";
I just need "ThisTextIsNeeded" and the starting and ending identifiers are same "/". I can use Substring but for that I will need different identifiers. Can anyone please guide me how to do it using similar identifiers in C#.
Edit: The string cannot be necessarily "NotNeeded/ThisTextIsNeeded/NotNeeded". It can also be changed for example "ABC/ThisTextIsNeeded/ABC" or "AAA/APPPP/ABC". I just need any text that comes in between / and /.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1- 您可以使用
正则表达式
输出: ThisTextIsNeeded
2- 或者,
分割
< code>string 通过使用 "/"输出:
list[1]
将是 -> 需要此文本1- You can use
regex
Output: ThisTextIsNeeded
2- Or,
Split
string
by using "/"Output:
list[1]
will be -> ThisTextIsNeeded