简体   繁体   中英

Using regex in Google Sheets how do I remove everything within the <> characters, including the characters themselves?

In my Google Sheet, I'm trying to delete the contents within any < > symbols, including the '<' '>'` symbols themselves.

For this example text: <h3>AJ Sports</h3> has been in business for 30 years

I want: 'AJ Sports has been in business for 30 years'

I've been using this regex formula =REGEXREPLACE(B2,"\s\<.*|\s\[.*","") but it also deletes everything after the last '>' .

With this regex, the output is: 'AJ Sports'

What do I need to add to only delete the desired portion and not the rest of the following text?

If you use this pattern:

\<[^>]*\>

it will see any open bracket < , and match with the closest closing bracket > , including the contents. More specifically, it will match with any string that contains an opening bracket, and a matching closing bracket .

Edit

RegexR showcase , explaining, and showing an example.

Try

=regexreplace(B2, "<.*?>",)

and see if that works?

例子

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM