Modify a digit surrounded by 2 letter characters

Advanced Renamer forum
#1 : 23/07-15 18:06
David
David
Posts: 59
I'm trying to Modify a digit surrounded by 2 letter characters or the reverse
For example m3n to men
H0mebuilding to Homebuilding
2O15 to 2015

So I want to be able to in the M3n instance
Find a digit character surrounded by 2 letter characters

Or the opposite, find a letter character surrounded by 2 digits

How do I do this

I know how to specify a number string (\d{4}) to specify a four digit number for example
And I'm sure there must be an equivalent expression to specify a text string but I can't figure out how to specify text.

Thanks.


23/07-15 18:06 - edited 24/07-15 02:51
#2 : 30/07-15 23:35
Tester123
Tester123
Posts: 92
Reply to #1:
Not exactly sure of what the overall rule is as the examples are quite varied, e.g. replace '3' with 'e', or 'number 0' with 'letter o' (will 4 be replaced with A for example, and 1's with I's, etc), but maybe here's something that might help a tiny bit...

To get 'a digit surrounded by 2 characters':
([A-Za-z]+)(\d)([A-Za-z]+)

To get 'a character surrounded by 2 digits':
(\d+)([A-Za-z])(\d+)

Each of the two examples has the same two components: '\d' and '[A-Za-z]'.

Explanation:
---------------
The () is used to define a group (which can later be identified by '\#' where # is the group number), e.g. \2 would be the second group (the single digit in the first case, and the single letter in the second case above)

\d is used to denote a single digit (i.e. 0 to 9).
[] is used to define a character set, basically any single character from the set.
So [A-Za-z] means: any single character in the range A-Z (uppercase), or a-z (lowercase). The hyphen specifies a range, so you don't need to list every single element, e.g. these would all be valid: A-Z, a-z, 0-9. Note these is no space separating the ranges, as a space is treated literally as a another character in the list.

The trailing '+' is a quantifier, and means one or more.
For comparison, there is another quantifier '*' which means zero or more.

Once you have the groups defined, you can manipulate them.

Note: the expressions above are to identify the general patterns as described (e.g. digit within letters, or vice versa), and don't actually solve your examples listed.


30/07-15 23:35 - edited 30/07-15 23:39
#3 : 09/08-15 02:34
David
David
Posts: 59
Reply to #2:
Tester thanks so much for the explanation it really helps a lot for many scenarios I can see I have come across previously and many in the future. Even though the formula doesn't specifically do what I want it really shows me what I really needed to know how to do.

I already know the instances that have inaccurate spelling being used so I just needed to know how to specifically refer to letter characters vs digit characters and your explanation has taught me how to do that so thanks again for your effort in helping out someone you never met.

Cheers From Canada.


09/08-15 02:34