News for hackers. Stuff that matters.
Re:YouTube was launched as a dating site by kleiba on Sunday July 21, 2019 @04:51PM (#20493575)
OT: in Emacs, you could prevent this from happening by using C-u M-% (replace-word): in that case, only those instances of "div" that are separate words (not parts of other words) will be replaced.

How would you avoid "inpiduals" (and similar mistakes) in other editors?

Re:YouTube was launched as a dating site by mehrdadn on Sunday July 21, 2019 @05:00PM (#20493639)
"Match whole words" is pretty common. And in every editor invariably ends up disagreeing with you on what precisely constitutes a word boundary.
Re:YouTube was launched as a dating site by Kudos on Sunday July 21, 2019 @06:00PM (#20493932)
In this particular case I would just have included the starting < in the search and replace.
Re:YouTube was launched as a dating site by frereubu on Sunday July 21, 2019 @06:19PM (#20494027)
You mean div> otherwise it wouldn't pick up the closing tags :)
Re:YouTube was launched as a dating site by keerthiko on Sunday July 21, 2019 @07:05PM (#20494250)
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.
Re:YouTube was launched as a dating site by frereubu on Sunday July 21, 2019 @06:41PM (#20494126)
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.
Re:YouTube was launched as a dating site by stefco_ on Sunday July 21, 2019 @05:01PM (#20493640)
In vim: :%s/\<div\>/p/g (add C at the end if you want to confirm each change)
Re:YouTube was launched as a dating site by bch on Sunday July 21, 2019 @05:54PM (#20493902)
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...

Re:YouTube was launched as a dating site by stefco_ on Monday July 22, 2019 @11:27AM (#20498909)
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.
Re:YouTube was launched as a dating site by whyenot on Sunday July 21, 2019 @05:39PM (#20493836)
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.
Re:YouTube was launched as a dating site by flear on Sunday July 21, 2019 @04:57PM (#20493620)
Just replace div> with p> ?