Notepad++ - Select whole line that contains a string with space

23,210

Solution 1

What's the correct regex command?

(.*State\sProvince.*) works for me.

enter image description here

Please check the other settings in the "Find" dialog.


Further reading

Solution 2

That works just fine for me. You might have an extra space, so try adding an asterisk after the \s, so it reads (.*State\s*Province.*)

Share:
23,210

Related videos on Youtube

deathlock
Author by

deathlock

Regular user.

Updated on September 18, 2022

Comments

  • deathlock
    deathlock 3 months

    I want to select whole line that contains the word State Province.

    Fro the Search menu > Find, using (.*State.*) will select whole line that contains the word State. But using (.*State\sProvince.*) does not.

    What's the correct regex command?

    • AFH
      AFH almost 6 years
      Some points: (1) it's generally better to ensure the whole line matches, regardless of any RE flavours or settings, by using ^ and $ (inside or outside the brackets, though these seem unnecessary); (2) you can use a literal space instead of \s; (3) if you select State Province before Find then the string will appear as the default search string, to which you can add the pre- and post-ambles; now (4) you can replace the space with \s if you wish, and you may see other characters in the document string, including duplications, tabs or other space characters (eg non-breaking).
  • deathlock
    deathlock almost 6 years
    My mistake, I mistyped! Should've slept before doing more work last night. Thanks.