English 中文(简体)
Regex发现并替换(c# .net)
原标题:Regex find and replace (c# .net)

我有很长的超文本页作为示意图。 在整个过程中,我有像这样的文字:

cid:@(Model.MyImage)

我已经扼杀了这条道路,并延长了档案。 我现在要取代以上段落,以取代。

[mypath]MyImage.[myExtension]

因此,我要抓住一下我时代的文本,在我新的扼杀中加以利用,然后消除所有恶果: st脚,把标准的道路上走。

因此,酸:@(Model.MainChart)可能变成 C:MainChart.png

http://www.ohchr.org。

在下面的答复中,这个问题得到了很好的回答。 下面的使用实例:

string first = @"<img src=""cid:@(Model.FirstOne)"" style=""max-width:600px;"" then <img src=""cid:@(Model.Another)"" style=""max-width:600px;"")";
            string pathPrefix = @"C:";
            string extension = ".png";
            string newPath = Regex.Replace(first, @"cid:@(Model.([^)]*))", pathPrefix + "$1" + extension);
最佳回答

我在此建议你。 The Regex is:

cid:@(Model.([^)]*))

替换体内应包含一个“<1>$,用于发现图像。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签