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.
Please check the other settings in the "Find" dialog.
Further reading
- FAQ Desk: Where to find REGEX documentation ? | Notepad++ Community
- Notepad++: A guide to using regular expressions and extended search mode
- Regular Expressions Tutorial
- RegExr: Learn, Build, & Test RegEx
- regex101: Online regex tester and debugger
- RegExper: Regular Expression Visualiser
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.*)
Related videos on Youtube

Comments
-
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 wordState
. But using(.*State\sProvince.*)
does not.What's the correct regex command?
-
AFH almost 6 yearsSome 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 selectState Province
beforeFind
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 almost 6 yearsMy mistake, I mistyped! Should've slept before doing more work last night. Thanks.