[英]sed find replace regular expressions windows
I have a latex file that contains many such expressions such as \\find{101.3}
我有一个包含许多此类表达式的乳胶文件,例如
\\find{101.3}
What I want to do is some form of preprocessing with a batch file running on windows that replaces these expressions with: \\replace{101}\\and{3}
我想做的是某种形式的预处理,在Windows上运行批处理文件,将这些表达式替换为:
\\replace{101}\\and{3}
I assume I will need to use regular expressions. 我假设我将需要使用正则表达式。 Using Unix I know I can do this with
sed
and I have something that works. 使用Unix,我知道我可以使用
sed
做到这一点,并且我有一些sed
东西。
sed -e 's/\\\\find{\\([0-9]*\\)\\.*\\([0-9]*\\)}/\\\\replace{\\1}\\\\and{\\2}/g' $1.tex>$1d.tex
But how can I transfer this to the windows batch language? 但是如何将其转换为Windows批处理语言?
Ouch. 哎哟。 I've recently have seen some batch kungfu with string search and replacement, but I heavily doubt it is directly possible with complex regex.
我最近看到了一些具有字符串搜索和替换功能的批处理功夫,但是我非常怀疑使用复杂的正则表达式是否可以直接实现。
Does it REALLY have to be a batch file? 真的必须是批处理文件吗?
Have you considered ie: 您是否考虑过:
I personally dont like powershell so I've set a PIK & Ruby 1.9.3 for such small tasks. 我个人不喜欢powershell,所以我为这样的小任务设置了PIK和Ruby 1.9.3。 It also imediatelly grants me a minimal GNU, so
它也立即授予我最小的GNU,所以
pik 193
ls -al | grep foo
works like a charm. 奇迹般有效。 On windows console.
在Windows控制台上。
edit: 编辑:
An example of string substitution in batch files: https://superuser.com/a/362405/233273 (though, NOT regex. Just constant->-constant replacement). 批处理文件中字符串替换的示例: https : //superuser.com/a/362405/233273 (尽管不是regex。只是常量->-常量替换)。 Some answers to that question also give an example of similar thing in powershell, and there regex would be accepted too.
该问题的一些答案也给出了Powershell中类似事件的示例,并且正则表达式也将被接受。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.