I have these inputs:
DFDBDFDFDF21R123
DFDBDFDFDF34R123
I want to match these inputs, except positions 9 and 10, like below:
DFDBDFDFxxR123
DFDBDFDFxxR123
So, to be clear: match 1-8, exclude 9-10, match 11-16.
I have these inputs:
DFDBDFDFDF21R123
DFDBDFDFDF34R123
I want to match these inputs, except positions 9 and 10, like below:
DFDBDFDFxxR123
DFDBDFDFxxR123
So, to be clear: match 1-8, exclude 9-10, match 11-16.
To expand upon the answer from https://stackoverflow.com/users/557597/sln of
(.{8})..(.+)
The 'thing' you are missing from your understanding of Regex is 'grouping'
(SOME MATCHING SUB-STRING A)(SOME MATCHING SUB-STRING B)
If you use regex like this, you can do lots of nice things including 'pull out' parts of a line and then re-arrange them. But it also helps you group 'parts' that you want to search for.
so his
.{8}
matches '.' which is 'any single character' and then {8} means 'match any single character 8 times.
(.{8})
means 'group the first 8 characters' for use.
..
means 'match any two characters'
.+
means 'match 1 or more of 'any character'
(.+)
means "group that 1 or more of 'any character' for later use"
Therefore...
When you put them all together you get
(.{8})..(.+)
Which means 'match the first 8 characters (any 8 characters) as group 1' then 'any two characters' then '1 or more characters as group 2'
This would allow you to (depending on your regex client/etc.) is use $1 and $2 to print out, use or ...whatever... the values of group 1 and/or group 2.
Hope this helps.