Not as Robust as Brian's solution but we have a lot of this, from banks in particular where the filename is a complex, multi-part filename with a known delimiter.
We do a fair bit of this with REGEX Match Get Group.
i.e. your example:
xxxxxxxxx_yyyyyyyy_304853637_94245342__2014-05-04.PDF (Current Filename variable set to this)
_{REGEX(MatchGetGroup|{USERVAR(Current Filename)}|(.*)_(.*)_(.*)_(.*)_(.*)_(.*)|3)}_{PATH(GetExtension|{USERVAR(Current Filename)})}
Yields:
_304853637_.PDF
Yes the delimiter is hard coded in the set variable . . . . but it is in the file (& regex) anyway. . . .
And further we sometimes have just one section we want to lose so we end up with this sort of thing:
{REGEX(MatchGetGroup|{TRIGGER(d9a226ae-0ad2-42fb-b518-1efd5af13bf7|LastTrigger|File.Result.Name)}|(.*)-(.*)-(.*)-(.*)-(.*)|1)}-
{REGEX(MatchGetGroup|{TRIGGER(d9a226ae-0ad2-42fb-b518-1efd5af13bf7|LastTrigger|File.Result.Name)}|(.*)-(.*)-(.*)-(.*)-(.*)|2)}-
{REGEX(MatchGetGroup|{TRIGGER(d9a226ae-0ad2-42fb-b518-1efd5af13bf7|LastTrigger|File.Result.Name)}|(.*)-(.*)-(.*)-(.*)-(.*)|3)}-
{REGEX(MatchGetGroup|{TRIGGER(d9a226ae-0ad2-42fb-b518-1efd5af13bf7|LastTrigger|File.Result.Name)}|(.*)-(.*)-(.*)-(.*)-(.*)|5)}
Section 4 being Problematic above and being excluded.
Have done so in other REGEX examples on the VisualCron forum but we *always* run complex regex through a set variable task and then use the resulting variable as a self documenting way to show in the logs what happened.
http://www.visualcron.co...sts&t=3437#post16201 Historically we kicked out to Powershell for a lot of REGEX and other complexity, but thankfully this is happening less and less with VC
You may find this helpful in your travels :
http://regexpal.com/ <I am not in anyway affiliated with this site, just a user !>
Cheers
Kevin
Edited by user
2014-05-15T03:44:39Z
|
Reason: Added the Link to the Earlier REGEX Post