Editing help needed

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Editing help needed

Post by terrypin »

I'm floundering a bit here and would much appreciate some help please.

I have text lines like this:

25-10-2017, 10 20 12
xyz 25-10-2017, 10 20 20
abc 25-10-2017, 11 01 05
26-11-2017, 11 01 14
Z 25-10-2017, 11 01 18
27-09-2017, 11 04 08

IOW, always a string like this (representing dates/times)
25-10-2017, 10 20 12
which may or may not be preceded by a purely alphabetc string, and if it does there will be a separating space.

I want the result to ignore the prefix and take this form:
25102017-102012
27092017-110408
etc

Terry, East Grinstead, UK
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

Here's one way to do it:

Find what: (.*_)?([0-9]{2})-([0-9]{2})-([0-9]{4}),_([0-9]{2})_([0-9]{2})_([0-9]{2}) [replace the underscores with spaces]
Replace with: \2\3\4-\5\6\7

Select Regular expression.
Click Replace All.
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Post by terrypin »

Thanks, but although I'm pretty sure I have entered that accurately it doesn't seem to work. On my examples it gives these results:

25-10-2017, 10 20 12
xyz25102017-202020
abc25102017-010105
26-11-2017, 11 01 14
Z25102017-010118
27-09-2017, 11 04 08

It should be:
25102017-102012
25102017-202020
25102017-010105
26112017-110114
25102017-110118
25102017-010118
27092017-110408

EDIT Monday 30 October 2017, 0854

If I modify your Find suggestion slightly to this:

(.* )([0-9]{2})-([0-9]{2})-([0-9]{4}), ([0-9]{2}) ([0-9]{2}) ([0-9]{2})

I get

25-10-2017, 10 20 12
25102017-102020
25102017-110105
26-11-2017, 11 01 14
25102017-110118
27-09-2017, 11 04 08

P.S: The formating tool (Bold) does not seem to work, although the setting BBCode is ON.

Terry, East Grinstead, UK
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

I'm not sure why my suggestion didn't work for you. I checked it again in both TextPad 7.6.4 and 8.1.2 and I got the desired results.

Maybe try copying and pasting from the following blocks:

Find what:

Code: Select all

(.* )?([0-9]{2})-([0-9]{2})-([0-9]{4}), ([0-9]{2}) ([0-9]{2}) ([0-9]{2})
Replace with:

Code: Select all

\2\3\4-\5\6\7
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Post by terrypin »

Clearly some careless mistake by me. Works fine now, thanks!

Terry, East Grinstead, UK
Post Reply