English 中文(简体)
ed——我的更换有什么错误?
原标题:sed - what s wrong with my replacement?
  • 时间:2012-05-17 10:06:28
  •  标签:
  • regex
  • sed

我有一份300多份档案清单,必须加以编辑,因此,认为这些档案与发现站在一起,可以帮助我。

在做错事之前(如我获得的超标准档案,或像这样的文件),我决定用手法,将结果变成当地的替代物。

斜体探测是指:<tr><td category=“button”风格=”背景:#0404;彩色:#eee9dc; font-size: 23px; pavention:5px 0;text-align:center;”><a href= ;Z2/C24357-0/hcm-LAST/MINUTES.html”风格=“案文-decoration:none; 曲线:色;#9eed&t&t。

而我只想取代<代码><a href=”。

页: 1 I m a noob about regex, i ll take a look at that web page ,使我以体面的方式进入regex论证。

现在,一味尝试这样的东西(在单一档案中,只是以“安全”的方式看待产出)

 sed s/<a.*LAST.*html"
      /<a href="../../../special_offers.php?lang=en"/ 
      C25030-9_3/hhcm-Solo_per_due.html

and I get that error: sed: -e expression #1, char 20: unterminated s command like the sed expressions isn t correct, but I don t know if the error is into the replacement part or somewhere else.

从现在起,感谢你的时间和努力。

S.

<><>Edit>>

由于回答,我通过做一些事情来解决这个问题。

sed  s/<a.*LAST.*html"/<a href="../../../special_offers.php?lang=en"/  C25030-9_3/hhcm-Solo_per_due.html
最佳回答

首先,你似乎需要将整条表述(s/.../)放在单一引文中,其次,你在结尾(见edit)上放弃<>/;第三,不要忘记,只有在整条插图按一行的情况下,替代才能奏效。

EDIT: More info on s command (see here, for example): it s s/old/new/ and possible flags after the last /. Your command looks like s/something/somethingelse/somethingelse, it has more than it should, I think.

问题回答

暂无回答




相关问题
Uncommon regular expressions [closed]

Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

Is it possible to negate a regular expression search?

I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签