Select the word around the given index in a given string In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.
(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)
For example, let | be your cursor in abc de|f ghi.
Then, when you double click, the substring def will be selected.
Input/Output
You will be given two inputs: a string and an integer.
Your task is to return the word-substring of the string around the index specified by the integer.
Your cursor can be right before or right after the character in the string at the index specified.
If you use right before, please specify in your answer.
Specifications (Specs)
The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.
The string will only contain printable ASCII characters (from U+0020 to U+007E).
The word &quot;word&quot; is defined by the regex (?&lt;!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or &quot;alphanumeric characters in ASCII including underscore&quot;.
The index can be 1-indexed or 0-indexed.
If you use 0-indexed, please specify it in your answer.
Testcases
The testcases are 1-indexed, and the cursor is right after the index specified.
The cursor position is for demonstration purpose only, which will not be required to be outputted.
string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd
V, 10, 9 7 bytes
À|diwVp

Try it online!
This answer uses 1-based indexing.
This could be shorter if we do exactly what the title says: &quot;Select the word around the given index in a string&quot;. We could do
À|viw

Which literally selects the word, but unfortunately doesn't change the output at all. So we need a little workaround to make it work by cutting it into a register, deleting the rest of the text, then pasting the register back in.
Explanation:
À|          &quot; Jump the position of argument 1
  diw       &quot; (d)elete (i)nside this (w)ord.
     V      &quot; Select this line
      p     &quot; And replace it with the word we just deleted