c# - 使用 C# 的正则表达式

标签 c#

这是我的输入:

27:15 And Rebekah took goodly raiment of her eldest son Esau, which^p were with her in the house, and put them upon Jacob her younger son:^p 27:16 And she put the skins of the kids of the goats upon his hands,^p and upon the smooth of his neck: 27:17 And she gave the meat^p and the bread, which she had prepared, into the hand of her son Jacob.

这里^p是回车

它应该作为 27:15 contents 在一行中添加到数据库中,在另一行中作为 27:16 contents...

使用我试过的正则表达式:

var m = Regex.Match(line, @"\n\d+:");
if (m.Success)
 {
   html = html.Replace(m.Value, "</p>\n<p>" + m.Value);
 }

我的输出是这样的:

2
7:15 contents

我想存储 27:15 内容..我试过了,但没有得到答案。

最佳答案

我建议你改变你的正则表达式

var m = Regex.Match(line, @"\d+:\d+")

它将在 27:15 返回给您

关于c# - 使用 C# 的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15333327/

相关文章:

C# 文件处理 : Create file in directory where executable exists

c# - .NET 3.5 中的 "An existing connection was forcibly closed by the remote host"

c# - 在 C# 中定义对象列表的困难

c# - 在 UIWebView 中调用 javascript 命令

c# - 打包项目错误 : 'Conflicting values for resource' and 'Duplicate Entry'

c# - 如何将项目列表从 View 传递到 Controller (ASP.NET MVC 4)

c# - OnCollisionEnter2D 发送信息失败

c# - 将 UI 和 API 组合到单个 Blazor 服务器应用程序中?

c# - 为什么可以在同一个类中创建的另一个线程中访问局部变量?

c# - 调试时异步行为同步?