Remove dash from date format

A swapping-ground for Regular Expression syntax

Remove dash from date format

Postby bmerri19 » Tue Apr 06, 2010 7:16 pm

Attempting to remove the dash in between a date string formatted as "04-01-10", but there is also text before and after the date. I can find the pattern via:
(\b\d{2}-\d{2}-\d{2}\b)

Stuck in removing the two dashes and keeping all existing text.

Thanks,
Brian
bmerri19
 
Posts: 1
Joined: Tue Apr 06, 2010 7:12 pm

Re: Remove dash from date format

Postby Stefan » Tue Apr 06, 2010 7:58 pm

bmerri19 wrote:Attempting to remove the dash in between a date string formatted as "04-01-10", but there is also text before and after the date. I can find the pattern via:
(\b\d{2}-\d{2}-\d{2}\b)

Stuck in removing the two dashes and keeping all existing text.

Thanks,
Brian

Hi Brian, welcome.

Please provide always full examples of your file names, so we have an change to help you.
Here are a few guesses of me:

Form:
Before 04-01-10 After.txt
To:
Before 040110 After.txt
Use:
Remove(5) Chars:[-]



Form:
Before 04-01-10 After.txt
To:
Before 04 01 10 After.txt
Use:
Repl.(3)
Replace: -
With: blank



Form:
Before 04-01-10 After - test.txt
To:
Before 040110 After - test.txt
Use:
RegEx(1)
Match: (.*?)-(.*?)-(.*)
Repla: \1\2\3




or better for all kind of dashes on different places:

Form:
Before - 04-01-10 After - test.txt
Before 04-01-10 After - test.txt
Before-Test 04-01-10 After.txt
To:
Before - 040110 After - test.txt
Before 040110 After - test.txt
Before-Test 040110 After.txt
Use:
RegEx(1)
Match: (.*\d\d)-(\d\d)-(\d\d.*)
Repla: \1\2\3 [ or \1 \2 \3 or \1.\2.\3 , whatever one likes ]
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions


cron