- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用竖线分隔的文件。目前,我使用 Notepad++ 查找并替换 REGEX 模式 ^(?:[^|]*\|){5}\K[^|]*
将第 5 行之间的所有行替换为空字符串和第 6 个 |
。我正在尝试以编程方式执行此过程,但 .NET 不支持 \K
。我已经尝试了几个向后查找的实例,但我似乎无法理解它。
string[] lines = File.ReadAllLines(path);
foreach (string line in lines)
{
string line2 = null;
string finalLine = line;
string[] col = line.Split('|');
if (col[5] != null)
{
line2 = Regex.Replace(line, @"^(?:[^|]*\|){5}\K[^|]*", "");
最佳答案
\K
是不支持锚定 look-behind assertions 的正则表达式语法/引擎的“解决方法” .
.NET 的正则表达式语法 has look-behind assertions (使用语法 (?<=subexpression)
),所以使用它们:
Regex.Replace(line, @"(?<=^(?:[^|]*\|){5})[^|]*", "")
在 .NET 的上下文中,此模式现在描述:
(?<= # begin (positive) look-behind assertion
^ # match start of string
(?: # begin non-capturing group
[^|]*\| # match (optional) field value + delimiter
){5} # end of group, repeat 5 times
) # end of look-behind assertion
[^|]* # match any non-delimiters (will only occur where the lookbehind is satisfied)
关于c# - 将 Notepad++ REGEX 转换为 .NET C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66497484/
我需要删除某个字符后的所有内容。 例如以下行: email:pass | text | text | text | text 我如何删除"pass"之后的所有内容,使其最终像这样: email:pas
我看到一旦我打开一个新文件并在其中写入一些内容,即使我不保存它,当我再次打开 notepad++ 时,该文件也会打开。那么如何在notepad++中保存工作区的状态,即使我不保存呢?任何人都可以指出它
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 7年前关闭。 Improve this qu
这个问题听起来可能很愚蠢。 我正在使用 NP++ 6.8.8(我添加主页的最新版本) 我想使用函数列表(基本上如 here 所述), 没什么特别的,只是为了看看 PHP 函数。 我可以打开功能列表窗口
我有一个包含数字和字符的文本文件(阿拉伯语) 像这样: 943894رنيش964737 ترشقة1045051 ضمنزلبالق10653 对此: 943894964737 1045051 10
我有一些命令行工具,有时需要在外部编辑器中调出文件才能进行编辑。这些工具依赖于编辑器的阻止行为:退出编辑器程序后,他们希望文件已被修改和保存。 但是,这不是Notepad++起作用的方式。从命令行启动
我正在努力弄清楚如何在 Notepad++ 中替换日期格式 我有一个包含不同日期的 key 。 2014/01/03 应改为: 2014-01-03 等等。 关于如何做到这一点的任何建议? 最佳答案
有没有办法为 Notepad++ 创建自定义命名区域来折叠它们? 我看过一些关于它的讨论,但没有找到如何操作的功能示例。 最佳答案 我用: //{ NAME OF REGION/BLOCK //} 关
我想知道是否有可能在Notepad++的“查找文件”功能中列出文件过滤器中的排除项。 例如,以下内容将在所有文件中用Dog替换Dog。 查找内容:狗 替换为:猫 过滤器:*。* 我想做的是在.sh文件
我在我的 Windows 机器上使用 Notepad++,我错误地打开了一个 64MB 的文件。现在我的 Notepad++ 被永久卡住了,我无法使用它。 Notepad++ 是否有任何配置文件来维护
这个问题可能有点跑题,但我无法从其他任何地方获得帮助。 早期的 Notepad++ 在菜单中有Stream Comment 和Toggle Block Comment 选项,但现在找不到了。无论如何要
是否有某种 CSS tidy 可用于 Notepad++。我已经尝试过似乎是 TEXTFX 中的每个菜单项,但似乎都没有。我习惯于使用 PSPAD,您只需选择 CSS 并单击“重新格式化为结构化 CS
嗨,我正在编辑要在我的数据库中使用的 csv 文件。从几个星期开始,当我用 Notepad++ 打开它时,我发现最后有一个坏字符,它像 CR 一样破坏了我的文件。 IE "30-APR-2014","
当我每天在工作中使用Notepad ++时,我想对其进行扩展以提高工作效率。 我想做的是选择包含单词的多行,右键单击并单击一个菜单项,例如“逗号分隔”,然后将所有单词放在一行中以逗号分隔。 我知道No
我有一个 C++ 源文件,它使用 getMemberName() 形式的函数返回成员数据。相反,我想使用 memberName()。 为了匹配需要更改的函数名称实例,我使用了以下正则表达式: (\s+
我导出了一个显示服务器备份状态的备份报告,服务器有一个父作业和子作业。报告状态仅与父作业相关的行相关,子作业提供无关信息。父作业包含关键字“每周”。如何显示报告以仅显示带有 Weekly 一词的行,应
我知道如何使用“运行->运行”或F5自动运行命令。我也知道如何使用快捷方式保存命令。我的问题是,考虑到我已经保存了一条快捷方式的命令,并且该命令现在出现在“运行”菜单中,并且我忘记了要输入的内容作为运
Notepad++是否可以导航到定义?我想给它一个我的库所在的目录,搜索它并在新选项卡的引用行中打开源/头文件。很像NetBeans。 我刚刚安装了SourceCookifier,这很好,但是除了已经
情况: 在 n++ 中打开一个文本文件,进行一些修改,按 ALT-F4 或关闭程序。N++ 不会询问“是否要保存更改”。相反,它会退出并且硬盘上的文本文件保持不变。 但是当我再次打开 N++ 时,MO
我喜欢 Notepad++ 。它做了我需要它做的一切。我不需要一个花哨的 IDE,我从命令行使用 makefile 进行编译,而且我从事的项目并不是非常大,它们只是变得越来越小。这张图片很好地描述了我
我是一名优秀的程序员,十分优秀!