Fix timing format
-
hello everyone
i woud like to ask if somone help me about this situation
i need to fix subtitle timing format i open the file with notepad++
and it was like this
1
00:01:19747 --> 00:01:21624- bla bla
2
00:01:35596 --> 00:01:37890-
- bla bla
3
00:01:57368 --> 00:01:59995- bla bla
4
00:02:01872 --> 00:02:03874- bla bla
5
00:02:15845 --> 00:02:19390- bla bla
6
00:02:23143 --> 00:02:25020
bla blabut in fact the right timing will be like this :
1
00:01:19,747 --> 00:01:21,624- bla bla
2
00:01:35,596 --> 00:01:37,890-
- bla bla
3
00:01:57,368 --> 00:01:59,995- bla bla
4
00:02:01,872 --> 00:02:03,874- bla bla
5
00:02:15,845 --> 00:02:19,390- bla bla
6
00:02:23,143 --> 00:02:25,020
bla blathe problem in time format ( , )
is there any way to add ( , ) afters second number by fast way because its more than 5000 lines so i cant change one by one -
@Mohammed-Fouad said in Fix timing format:
is there any way to add ( , ) afters second number
Yes, Notepad++ has regular expression (regex) search and replace, which makes that easy to do.
FIND WHAT =
(:\d\d)(\d\d\d)
REPLACE WITH =$1,$2
SEARCH MODE = regular expresionThe find expression defines two groups – the first has a colon and two digits; the second is three digits. Those values are stored and you can refer to them in the replacement expression using the $1 and $2. Since you want a comma between the first group and the second, that’s what you say.
There are actually a lot of ways to do it. Getting fancier, with quantifiers to define how many digits before and after, and with using lookbehind and lookahead, you can make the match more complicated but the replacement much simpler:
FIND WHAT =(?<=:\d{2})(?=\d{3})
REPLACE WITH =,
SEARCH MODE = regular expression
(This works because the combo of the lookbehind and lookahead means the match is technically 0 characters wide, just between the second and third digit, so you are “replacing” those 0 characters with the single,
character.)More generic advice, including links to docs, and hints for asking questions better here (you did a good job, with showing us before and after data, so thanks; I just paste this generic advice for most of my answers to first-time search/replace questions.)
----
Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the
</>
toolbar button or manual Markdown syntax. To makeregex in red
(and so they keep their special characters like *), use backticks, like`^.*?blah.*?\z`
. Screenshots can be pasted from the clipboard to your post usingCtrl+V
to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries. -
@PeterJones said in Fix timing format:
$1,$2
thanks so much you save my day
its working with me good