Add a character at the end of line in notepad++

I am using notepad++ and RegEx.

I have a SRT file and I want to add three question marks "???" whenever the first the three characters of a line are also three questions marks "???". However, I only wish to do this if the next line is blank. However, if the next line is not blank then I would like to add the ??? after the end of that next line.

For example this is that I have.

14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again

15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain

Now I would like to add the ??? like this to both the lines.

14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again ???

15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain ???

Answers


Notepad++ used to have problems with multiline matches, but the current releases are said to support Perl-style regexes much better. I don't have Notepad++ installed, but if its regex engine works correctly, then the following regex should solve your problem:

Search for (?s)^(\?{3}.*?(?=\r?\n\r?\n|\z)) and replace with \1???.

Explanation:

(?s)         # Turn on dot-matches-all mode
^            # Match start of line
(            # Match and capture (group 1)
 \?{3}       # Three question marks
 .*?         # Any number of characters, as few as possible
 (?=         # until the following regex can be matched at the current position:
  \r?\n\r?\n #  Either two newlines in a row
 |           # or
  \z         #  the end of the file
 )           # End of lookahead assertion
)            # End of capturing group 1

Need Your Help

Access global variables through Helper

javascript localization handlebars.js

How can I access a global variable through a helper function in Handlebars.js for the purpose of localization? Here's what I've got so far. The problem I'm seeing is that the parameter 'string' is

Default IMarshal implementation?

.net windows multithreading com marshalling

I am trying to implement registry-free COM explicilty in my code (can't use registry-free COM via an app manifest since that only works on the exe level): I create a static class that loads the COM...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.