This question may have been listed but I was not able to find one exact hit.
I am trying to skim through a file, match a pattern and replace it with something else. However there are other occurrences of the pattern but I need to replace only those which are 17 characters in length.
Example:
Content:
dlkfhfd|fedfe|dfwe3f347fde|3745978|dlkfhr**|376663781736102|**fedfe|dfwe3f347fde
Expectation:
dlkfhfd|fedfe|dfwe3f347fde|3745978|dlkfhr**|37xxxxxxxxxxxxx|**fedfe|dfwe3f347fde
Progress:
I was able to match the expression with regexp pattern : **\|37[0-9]{13}\|**
However if I put it in an sed
, it just replaces everything in the file.
sed -e s/\|37[0-9]{13}\|/\|37xxxxxxxxxxxxx\|/g
My sed version is 4.2.2