You can try something like this (I just did it quickly so the regular expression I am sure can be bettered, and you can customize it if there are more lines that you are not showing us
local loReg, lcString, loMatches, loMatch, loSubmatch
clear
text to lcString noshow flags 1 pretext 1 + 2 + 4
F5 B (Total Charges)390 478 w
F5 B (Total Chg)390 478 w
F5 B (Total Chrgs)390 478 w
endtext
loReg = CreateObject('VBScript.RegExp')
loReg.Pattern = '.*(\(Total cha?r?g?e?s?\)(\s?390)\s)(\d+)\s?w'
loReg.Global = .t.
loReg.IgnoreCase = .t.
loMatches = loReg.Execute(lcString)
if loMatches.Count > 0
for each loMatch in loMatches
loSubmatch = loMatch.SubMatches.Item(2)
? 'Total charges:', loSubmatch
endfor
else
? 'No matches found'
endif
[Update]
By the way, I forgot to say that you should replace the TEXT ENDTEXT with lcString = FILETOSTR('Your File')
[Update 2]
Just noticed that I called the variable loSubmatch instead of lcSubmatch...
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges