[ antp.be > Forum ]

[ FAQFAQ - SearchSearch - MemberlistMemberlist - UsergroupsUsergroups - ]

[ RegisterRegister - ProfileProfile - Log in to check your private messagesLog in to check your private messages - Log inLog in ]


Using Lookbehind to remove some information at EOF name

 
Post new topic   Reply to topic    www.antp.be Forum Index -> Ant Renamer > Help
Author Message
wolfkin
PostPosted: 2017-10-12 21:56:22    Post subject: Using Lookbehind to remove some information at EOF name Reply with quote
View user's profile Send private message https://regex101.com/r/IgsZfH/3

This is what I have so far.

SampleFileNames:

Code:
SampleFileA-[SortCode].xls
SampleFileB-[SortCode][CRCNum].xls
SampleFileC-[SortCode][OtherSortCode][CRCNum].xls
SampleFileD-Date[CRCNum].xls
SampleFileE-Date.xls

In this example I only want to remove [CRCNum] from the file names.

This is as close as I can get. I just don't know how to use lookbehind properly


The RegEx

Code:
(?<!\-)\[.+?\](\.\w{3}$)


Code:
$1


The Error



Code:
<RegExp Error> TRegExpr(Comp): Urecognized Modifier (pos 6)


And finally the ideal outcome

Code:
SampleFileA-[SortCode].xls
SampleFileB-[SortCode].xls
SampleFileC-[SortCode][OtherSortCode].xls
SampleFileD-Date.xls
SampleFileE-Date.xls
antp
Site Admin
PostPosted: 2017-10-13 09:20:00    Post subject: Reply with quote
View user's profile Send private message Visit poster's website What's the "rule" that you try to write?
I do not see the link between your regex and the sample confused
How could the regex spot the difference between cases A & D ? (i.e. detect what is CRCNum and SortCode)
Display posts from previous:   
View previous topic :: View next topic  
Post new topic   Reply to topic    www.antp.be Forum Index -> Ant Renamer > Help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
Template made by antp