Find/Replace regex to remove html tags

后端 未结 5 775
别那么骄傲
别那么骄傲 2021-02-01 22:17

Using find and replace, what regex would remove the tags surrounding something like this:

5条回答
  •  野性不改
    2021-02-01 23:03

    String s = "";
    s.replaceAll ("(", "$2")
    res1: java.lang.String = Viticulture and Enology
    

    (Tested with scala, therefore the res1:)

    With sed, you would use a little different syntax:

    echo ''|sed -re 's|(|\2|'
    

    For notepad++, I don't know the details, but "[0-9]+" should mean 'at least one digit', "[^<]" anything but a opening less-than, multiple times. Masking and backreferences may differ. Regexes are problematic, if they span multiple lines, or are hidden by a comment, a regex will not recognize it.

    However, a lot of html is genereated in a regex-friendly way, always fitting into a line, and never commented out. Or you use it in throwaway code, and can check your input before.

提交回复
热议问题