Regex: Select only the first line

spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 812067
    • Gender:Male
  • point d’amour
Regex: Select only the first line

select only the first line of the text-file
Code: [Select]
^\A(.*)$
Insert any word in the beginning of file:
Search
Code: [Select]
^\A(.*)$Replace with
Code: [Select]
Word $1
Select the last line of the text-file
Code: [Select]
^(.*)$\z
insert word at the end of file
Search
Code: [Select]
^(.*)$\zReplace with
Code: [Select]
$1 Word
Add a new empty line at the beginning of file:
Code: [Select]
^\A(.*)$Replace cu
Code: [Select]
\r \1
Add a new empty line after the first line:
Search
Code: [Select]
^\A(.*)$Replace cu
Code: [Select]
\1 \r (after \r leave an empty space)
https://community.notepad-plus-plus.org/topic/12352/regex-insert-new-line-at-the-beginning-of-file/2


 

Search Tools