Regex to strip filenames

Post variable and regex related tips, questions.

Regex to strip filenames

Postby melvin » Tue Nov 25, 2014 9:33 pm

User support request:

I have 4 files that have variable data in them that are generated a few times a day. I need to strip the name to push them ftp. Need some help with rename. below is a listing of the 4 files then what they need to be renamed. basically, I need to strip 24 characters off the front. Appreciate your help....

EIGHTCHA_20141124_1620_gatein.txt RENAMED TO gatein.txt
EIGHTCHA_20141124_1620_gatout.txt RENAMED TO gatout.txt
EIGHTCHA_20141124_1620_testim.txt RENAMED TO testim.txt
EIGHTCHA_20141124_1620_testimdt.txt RENAMED TO testimdt.txt
melvin
Site Admin
 
Posts: 979
Joined: Thu May 25, 2006 10:20 am
Location: Santa Barbara, california

Re: Regex to strip filenames

Postby melvin » Tue Nov 25, 2014 9:34 pm

In a copy or ftp task, rename field, use the following:
([a-zA-Z0-9]{1,}.txt)<GROUP>group1

a-z matches lower case
A-Z matches upper case
0-9 matches any number
[a-zA-Z0-9] is a single character
[0-9] is a single number
{1,} specifies one or more of the previous character
( ) groups the regex
group1 returns the first group, in this case the group1 contains the characters after the _ and includes .txt.
melvin
Site Admin
 
Posts: 979
Joined: Thu May 25, 2006 10:20 am
Location: Santa Barbara, california


Return to Variables and Regular Expressions

Who is online

Users browsing this forum: No registered users and 1 guest

cron