Count words, but not HTML tags

chilly_bang

Board Regular
Joined
Jun 17, 2016
Messages
57
Hi
i want to count all words in a cell, but not those, which are placed between < and >. Or, count all words, which are placed between > and <.
How can i accomplish this? With regex it is a nobrainer, but in Excel - no clue:(
 
with regex search for <[^>]*> and replace with nothing, i get slightly different word amounts, as with your UDF. Could you explain me such difference? The numbers i get with your UDF are always a little bit higher, but i can't understand, what is counted differently.
I believe that you method is flawed. Example

"apple<some html tag>orange"

That text contains two words not in the html tag but if you replace the tag section with nothing, the result is "appleorange" which would be correctly counted as one word by any word-counter.
Try replacing the tag with a space (which is what our routines do) and see how it compares.
 
Last edited:
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,330
Latest member
ThatGuyCap

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top