问题描述
要将一下字符串中的红色字体部分用java正则表达式替换为空,正则表达式应该怎么样写? body/div[3][@class='content']/div[2][@class='content-outer']/div[2][@class='fauxborder-left content-fauxborder-left']/div[2][@class='content-inner']/div[2][@class='main-outer']/div[2][@class='fauxborder-left main-fauxborder-left']/div[2][@class='region-inner main-inner']/div[@class='columns fauxcolumns']/div[4][@class='columns-inner']/div[1][@class='column-center-outer']/div[@class='column-center-inner']/div[@id='main' and @class='main section']/div[@id='Blog1' and @class='widget Blog']/div[1][@class='blog-posts hfeed']/div[@class='date-outer']/div[@class='date-posts']/div[1][@class='post-outer']/div[1][@class='post hentry']/div[@id='post-body-6939041512073017223' and @class='post-body entry-content']/div[@id='post-body-6939041512073017223' and @class='post-body entry-content']
解决方案
正则表达式:\[(@class|@id)=[^\]]+\][ 和 ]要做转义:\[、](@class|@id)表示@class或@id[^\]]+表示非右中括号]的任意字符