skip to Main Content

For example:

  1. Oldcoin23
  2. coin

In this above two words i only need to get the second word ‘coin’

I searched the word ‘coin’ in Vs Code by pressing Ctrl + Shift + F. But I am getting both word as a result. I.e., ‘coin’ and ‘Oldcoin23’.

How can I get only the word of ‘coin’ and not any other word that contain the word ‘coin’ inside.

2

Answers


  1. Use this regex search pattern: (?<!w)coin(?!w). To use this, you need to check the regex box in the find menu.

    enter image description here

    The way the regex works is that it uses a negative lookbehind (?<!w) to discard any results that have a word character before them, and a negative lookahead to discard any results that have a word character in front of them, (?!w), and searches for the word coin.

    Login or Signup to reply.
  2. Enable regex mode for the find widget (use the / button or alt+r), and then put bcoinb in the search input. In Regex, b means to match word boundaries. Quoting regex101.com:

    b
    Matches, without consuming any characters, immediately between a character matched by w and a character not matched by w (in either order). It cannot be used to separate non words from words.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search