Is this the right way of matching every English word in Vim? (Vim RegEx)

Viewed 89

I am currently using this regex substitution string on an html, to match all English words in some lines and enclose them into a <bdo dir="ltr"> tag.

The reason I need to do this is because the site has both Arabic and English characters, and the Arabic ones need to be enclosed in a <bdo dir="rtl"> tag, since Arabic is read from right to left.

So I am using this regex substitution:

.,.+2s/\(\<\w*\>\)/<bdo dir="ltr">\1<\/bdo>/g

Is there a better way to go about this?

1 Answers

It's a lot to ask of regex, but it's a sensible approach if you're reasonably certain that the only sequences of \w characters in your documents are in fact English words. I would say try it and inspect some results and see if you get anything you don't like.

Related