"Match whole words" is pretty common. And in every editor invariably ends up disagreeing with you on what precisely constitutes a word boundary.
In this particular case I would just have included the starting < in the search and replace.
You mean div> otherwise it wouldn't pick up the closing tags :)
I believe replacing `<div`\'<p' and `/div`\'/p' are preferred so you can retain any tag properties (class, id, style, etc), but it could still leave behind any tags with superfluous spaces.
Re:YouTube was launched as a dating site
by codetrotter on Sunday July 21, 2019 @06:40PM
(#20494119)
If you replace div> then you will miss any opening tags that have attributes. E.g. <div class=baz> or <div id=foobar>.
In Vim I would do
:%s@\(</\?\)div@\1p@g
It’s a little bit convoluted but it replaces the tag names in both opening and closing tags and does not replace it anywhere else.Fair point...
Re:YouTube was launched as a dating site
by daveFNbuck on Sunday July 21, 2019 @04:57PM
(#20493611)
In many editors, you can use a regex match for word boundaries on either side of div, like \bdiv\d. Some also have a checkbox for the word matching functionality.
In vim: :%s/\<div\>/p/g (add C at the end if you want to confirm each change)
Huh - that’s confusing in the context of this example, but indeed tests fine on my system (nvi).
Since the “word” in question is “<div>”, I thought the \< was just an escape. I looked in various docs and the best I see in Tcl re_syntax(n) is \< and \> are synonyms for [[:<:]] and [[:>:]] respectively, which are constraints matching empty strings at the beginning and end of words, where a word a sequence of word characters... [a-zA-Z0-9_]
TIL, too...
Right? Totally nonintuitive! But easy enough to remember and type. I figured I wasn't the only one who found it a bit surprising ^_^
Re:YouTube was launched as a dating site
by allannienhuis on Sunday July 21, 2019 @05:23PM
(#20493746)
TIL what \< means. Thank you.
Open it in a web browser and then copy and past it into the editor as plain text.
Re:YouTube was launched as a dating site
by jjtheblunt on Sunday July 21, 2019 @04:57PM
(#20493619)
the underlying regex libraries often (like your emacs) have a symbol for word boundaries. emacs is great, though, agreed.
How would you avoid "inpiduals" (and similar mistakes) in other editors?