PHP Preg-Replace: "period with numbers on each side"
I am trying to clear csv with timecodes and subtitles and change the timecode format.
For example:
timecode_in, timecode_out, text
01:09:37.12,01:09:40.11,and we felt very close to them.
I need to replace all periods in the timecode with colons. But I need to filter it so that it doesn't change periods in the text.
I think there must be a way to say, "Where the period has a number on each side, replace it with a colon."
Can anyone help me? I've never used regular expressions before.
source to share
The way to say is lookbehind and lookahead statements
(?<=\d)\.(?=\d)
See here in Regexr
(?<=\d)
is a lookbehind assertion that provides the digit before the current position
(?=\d)
is a forward-looking statement that provides a digit before the current position
But these numbers are not part of the match!
source to share