c# - 从 C# 中的 url 字符串中获取数字部分
问题描述
我有一个如下所示的 URL 字符串:
https://example.com/app/1095600/example2234
我只想得到“ 1095600 ”
这个数字是可变的,可以是三位数或更多位数。
解决方案
如果数字始终位于同一位置(在 之后https://example.com/app/
),您可以用斜杠 ( ) 字符分割字符串/
并提取它:
string input = "https://example.com/app/1095600/example2234";
string result = input.Split("/")[4];
推荐阅读
- r - 在R中更改月份全名的德语月份缩写
- r - 图表底部的图例并水平显示
- java - org.hibernate.tool.schema.spi.CommandAcceptanceException:通过 JDBC 语句执行 DDL“如果存在组 CASCADE 则删除表”时出错
- javascript - 如何仅在按下提交按钮而不是更改搜索时更改显示
- python - python在excel中删除活动过滤器并打开分组
- sql - 仅列出在列中更改了某个值的用户
- dropbox - 无法在swift 5中显示列表并从保管箱上传文件
- python - 在 Pandas 中创建新列时将相同 ID 的多行合并为一行
- c# - 无法在 EF Core 中加载类型“Microsoft.EntityFrameworkCore.Internal.ProductInfo”错误
- c# - 我怎样才能找出这个 Channel Destruct 错误?