Alex Bliskovsky
Alex Bliskovsky

Reputation: 6303

Regular expressions in sed

I have a stream that looks like this (except with more stuff):

<ret:EditUse>Broadcast</ret:EditUse>
<EditUse>Movie</EditUse>

and I'm trying to clean the XML from it using sed:

sed "s_</?(ret:)?EditUse>__"

I've tested the regular expression using RegexPal but it doesn't seem to work in sed. Any ideas as to what's wrong?

Upvotes: 3

Views: 284

Answers (1)

Birei
Birei

Reputation: 36262

This is the regex that works with sed:

sed "s_</\?\(ret:\)\?EditUse>__g"
  1. Escape with backslash characters ?, ( and )
  2. Use g switch to apply the regex many times in each line.

Result:

Broadcast
Movie

Upvotes: 6

Related Questions