Hello,
Thanks for this wonderful and very useful tool.
I'm totaly not familiar with wild card and other expressions like regex. So please bear with me!
I'll just start off by providing you with an exemple i'm working on:
Multiple batch files containing only one line. here are two batch files for example:
1st file:
%SystemRoot%\explorer.exe /e,\\ctsvmainsaver\Documents\Documents Secteur Atelier Principal\Departements\5159-200 Tonnes\218-5220
2nd file:
%SystemRoot%\explorer.exe /e,\\ctsvmainsaver\Documents\Arborescence Mainsaver\USINE CRABTREE\SF 200 TPD PLANT\159-VENTILATION\404-7070
In both files (and in the other 1397 batch files awaiting me)the text to be replaced always starts from the end of the first '\documents\' and ends at just before the last '\' in the line. The replcement text is the same for both and all the other files: MACHINE-FIBRE-SERVICE\DOCUMENT PAR ACTIF
So here's how the 1st and 2nd files should like after a find and replace:
1st file:
%SystemRoot%\explorer.exe /e,\\ctsvmainsaver\Documents\MACHINE-FIBRE-SERVICE\DOCUMENT PAR ACTIF\218-5220
2nd file:
%SystemRoot%\explorer.exe /e,\\ctsvmainsaver\Documents\MACHINE-FIBRE-SERVICE\DOCUMENT PAR ACTIF\404-7070
How do I configure a regular expression or a Regex to do the job?
MAny thanks in advance for giving me a hand!!
Remplace text in middle on line
ok, I will try (without being too long winded about it).
here is a sample of lines in a text file
0 0 9 45 -45 45 -45 45 -45 45 -45
-27.49 0 1.2 'UNDEF' 'UNDEF' 0 1 0
'centre' 'I' 'N' 'N' 0 1
0 0 9 45 -45 45 -45 45 -45 45 -45
-0.5 0.06 0.99 'UNDEF' 'UNDEF' 0 1 0
'right' 'I' 'N' 'N' 0 1
0 0 9 45 -45 45 -45 45 -45 45 -45
26.72 0.02 1.5 'UNDEF' 'UNDEF' 0 1 0
in the second, fifth, and eighth line, I want to change the third numbers (1.2, 0.99, and 1.5) to zero.
These lines are best defined by the the constant 'UNDEF' content in each of the lines in question.
The number to be changed, will always be the 3rd number in the line.
Note that the line numbers will not be consistant from file to file, (eg will not be 2nd, fifth, and eighth).
thanks very much for you help
here is a sample of lines in a text file
0 0 9 45 -45 45 -45 45 -45 45 -45
-27.49 0 1.2 'UNDEF' 'UNDEF' 0 1 0
'centre' 'I' 'N' 'N' 0 1
0 0 9 45 -45 45 -45 45 -45 45 -45
-0.5 0.06 0.99 'UNDEF' 'UNDEF' 0 1 0
'right' 'I' 'N' 'N' 0 1
0 0 9 45 -45 45 -45 45 -45 45 -45
26.72 0.02 1.5 'UNDEF' 'UNDEF' 0 1 0
in the second, fifth, and eighth line, I want to change the third numbers (1.2, 0.99, and 1.5) to zero.
These lines are best defined by the the constant 'UNDEF' content in each of the lines in question.
The number to be changed, will always be the 3rd number in the line.
Note that the line numbers will not be consistant from file to file, (eg will not be 2nd, fifth, and eighth).
thanks very much for you help
Assuming that the lines always look the same, you could just replace "-?\d+(\.\d+)? 'UNDEF'" with "0 'UNDEF'".
This does not actually replace the third number but instead replaces any number (with or without decimal point, with or without minus sign) directly in front of a 'UNDEF' with a 0.
If I were to implement it how you phrased it, third number in all lines containing 'UNDEF' 'UNDEF', i would go for this:
"(-?\d+(\.\d+)? -?\d+(\.\d+)?) -?\d+(\.\d+)? (.*'UNDEF' 'UNDEF'.*)"
replaced with "$1 0 $5"
This looks really complex, but this is mainly because of all the optional decimal points and minus signs
This does not actually replace the third number but instead replaces any number (with or without decimal point, with or without minus sign) directly in front of a 'UNDEF' with a 0.
If I were to implement it how you phrased it, third number in all lines containing 'UNDEF' 'UNDEF', i would go for this:
"(-?\d+(\.\d+)? -?\d+(\.\d+)?) -?\d+(\.\d+)? (.*'UNDEF' 'UNDEF'.*)"
replaced with "$1 0 $5"
This looks really complex, but this is mainly because of all the optional decimal points and minus signs
If this description satisfies the request
"delete the number just before 'Undef'"
then you could use the following regular expression
_[\d\.]+_'UNDEF'
and replace each occurrence by
_0 'UNDEF'
where
_ represents a space character
[\d\.]+ matches any string of one or more characters of the set "0123456789." with the assumption that these will only be numbers with or without decimal point.
"delete the number just before 'Undef'"
then you could use the following regular expression
_[\d\.]+_'UNDEF'
and replace each occurrence by
_0 'UNDEF'
where
_ represents a space character
[\d\.]+ matches any string of one or more characters of the set "0123456789." with the assumption that these will only be numbers with or without decimal point.
Thanks again, but I am clearly missing something. Neither of the suggestions will work for me. I get the "no files found..." message.
When I edit the FIND to just look for UNDEF, it happily finds my files and the lines with this text.
it seems to be the coding that isn't working for me.
Is there another setting somewhere that I need to change. I am using textcrawler 'right out of the box'.
thanks
When I edit the FIND to just look for UNDEF, it happily finds my files and the lines with this text.
it seems to be the coding that isn't working for me.
Is there another setting somewhere that I need to change. I am using textcrawler 'right out of the box'.
thanks