How to match content between HTML specific tags with attribute using grep?

前端 未结 3 1020
时光说笑
时光说笑 2020-12-31 07:43

Which regular expression should I use with the command grep if I wanted to match the text contained within the tag

and it
3条回答
  •  离开以前
    2020-12-31 07:59

    Here's one way using GNU grep:

    grep -oP '(?<=
    ).*?(?=
    )' file

    If your tags span multiple lines, try:

    < file tr -d '\n' | grep -oP '(?<=
    ).*?(?=
    )'

提交回复
热议问题