I am using sed to replace all HTML tags in a file
Text:
Hello World!
I have checked that basic regular expressions <.*\?>
and <[^>]*>
match only HTML tags in the text.
When I use sed 's/<.*\?>//g' [input-file]
, sed
replaces everything and five blank lines are printed, whereas, sed 's/<[^>]*>//g [input-file]
produces the correct output and first prints two blank line, then Hello World! with appropriate indentation on the next line and last two blank line.
Why does it behave differently for similar matches?
No comments:
Post a Comment