1

How do I do a replace using TextPad for all date occurrences such as

01-Apr-2014 02-Apr-2014 03-Apr-2014

to

2014-Apr-01 2014-Apr-02 2014-Apr-03

I tried a bunch of regular expressions for the date, but can't even get it working once. Thanks.

Candice
  • 25
  • 6

2 Answers2

0

You can use this regex:

(\d+)-(\w+)-(\d+)

Working demo

And then change the order of capturing group index:

enter image description here

Federico Piazza
  • 30,085
  • 15
  • 87
  • 123
  • I tried it in TextPad, but i keep getting "Cannot find literal expression: (\d+)-(\w+)-(\d+)" – Candice Aug 15 '14 at 16:10
  • @Candice as you can see in my answer it works fine. I think that TextPad doesn't support this or it could have a bug. You can try using Notepad++ or even paste the text in regex101.com. Btw, if my answer answered to your question you may consider marking it as resolved. – Federico Piazza Aug 15 '14 at 16:19
  • i have text before and after the dates, so do i need a wildcard character in the regex and in the substitution? – Candice Aug 15 '14 at 19:22
0

The expressions below work in Textpad. Federico was using POSIX syntax which you have to specifically tell Textpad to use in Configure>Properties>Editor. Also, you got a "literal expression" not found, meaning you didn't check the regular expression checkbox in the search window.

Find What: ([0-9]+)-([a-z]+)-([0-9]+)
Replace With: \3-\2-\1

Search Box Image

Tobi Nary
  • 4,566
  • 4
  • 30
  • 50
Bil
  • 1