This is just a question out of curiosity - I was looking at this question and I'm wondering how you could go about making both needed replacements in one Regex Replace.
So, the situation is that we have the following input:
8.11.2012 16:15:10
21.11.2012 15:00:54
11.11.2012 0:24:24
8.11.2012 16:06:53
9.11.2012 0:49:37
And want to create the following output:
08_11_2012_16_15_10
21_11_2012_15_00_54
11_11_2012_00_24_24
08_11_2012_16_06_53
09_11_2012_00_49_37
In other words:
- Replace any single digits in time/date part of the string with "0" & Single character.
The solution posted works great for that:
Replace
\b(\d)\bwith0$1 - Replace any separator with "_"
And that would be simply replacing
[\s\:.]with_
My question is whether there was any way to do BOTH replacements in a single Regex or if it's absolutely necessary to do 2 replace iterations?
What would that look like??
Just trying to learn here - Thanks!!
Also, even though this question was asked for Notepad++, I use .Net (C# / VB).
DateTime.ParseExact(@"d\/M\/yyyy H\:mm\:ss")andDateTime.ToString(@"dd\_MM\_yyyy\_HH\_mm\_ss")- rather than regular expressions.