Forum Moderators: phranque
For example,
some file = some file
some file #*$! = some file 2
some file xxx xxx = some file 3
some file xxx xxx xxx = some file 4
some file xxx xxx xxx xxx = some file 5
ETC
There should never be more than 15 instances of xxx on a single line in case that matters.
Thanks so much!
Just want to make sure that isn't too confusing.
If I have:
someword
someword abc
someword abc abc
someword abc abc abc
someword abc abc abc abc
some phrase
some phrase abc
some phrase abc abc
I should end up with:
someword
someword 2
someword 3
someword 4
someword 5
some phrase
some phrase 2
some phrase 3
I hope that makes better sense.
I know I could do multiple search and replace to:
replace
abc abc abc abc
with
5
replace
abc abc abc
with
4
replace
abc abc
with
3
replace
abc
with
2
ETC and end up with
someword
someword 1
someword 2
someword 3
ETC
The problem is, that would end up being about 15 steps to do one thing and I want to do it all w/one single string. I know it can be done, just no idea how.
Thanks in advance!
So, anywhere that says #*$! should really be tripple x. Hope that makes sense. For some reason, it only appears to remove the first instance of the string which must be a bug. Anyway, just thought I'd point that out.
Jim
Actually though, this is more of a question about regular expressions and Search and Replace to replace one series of word combinations within a file with the new combinations. I'm using a search and replace application to do this and the results will then be used on my server so we can build a database that will utilize the results of the S & R.
I'm thinking something along the lines of:
Search for: a
Replace with: b
where
a = regular expression to find and count all instances of abc on a line
b = number of instances abc was found on given line.
Any idea how that might be done?