#1 : 01/05-24 01:39 John333
Posts: 3
|
Hello,
I have what I thought was a very simple use case, but I can't get the regular expression just right. I have several file names as such: Abcd5678.doc Acd745.doc Smn6457.doc The # of letters may vary slightly as may the # of following digits. I simply want to insert a dash between the last letter and the first digit. So my result would be: Abcd-5678.doc Acd-745.doc Smn-6457.doc I've played around with some similar examples I found here, but I can't get it right Any help would be appreciated. |
#2 : 01/05-24 02:40 Delta Foxtrot
Posts: 323
|
Reply to #1:
Hi John, Sure, no prob. This will do it: REPLACE method: To replace: "([a-zA-Z]+)([0-9]+)" <--- WITHOUT QUOTES Replace with: $1-$2 Occ: All Case sens.: No RegExp: YES Apply to: Name You are making two containers (denoted by parentheses, and called "capturing groups" in regular expression-ese) that ARen will remember to put into the replacement: The first for the alpha characters and the second for the numeric characters. The square brackets are called "character classes"–they simply define the types, or classes, of characters you are looking for. "a-zA-Z" says you will accept all alpha characters, but ONLY alpha characters. "0-9", of course, accepts numbers. The "+" plus sign after the character classes say match at least one of the character class up to any number. $1 in the replace slot is the first capturing group, etc. Best regards, DF |
#3 : 09/05-24 16:13 John333
Posts: 3
|
Reply to #2:
Thank you!!! |
#4 : 10/05-24 10:19 Delta Foxtrot
Posts: 323
|
Reply to #3:
Heck, if only all the problems were that easy... :) Best, DF |