I'm trying to write a regular expression that will find only the numbers in the string of text below:
MemTotal: 16328352 kB
I don't want the alphabetical or whitespace characters. I just want (in this example) "16328352".
I can't find a specification on a regular expression that will ignore certain data types, however.
You already have 4 options, why not one more 🙂 Try this
MemTotal:\s*(?<mem>\d+)"
Give this a shot
MemTotal\:\s+(?<MemoryTotal>[^\s]+)
edit - tried this and its working good.
sourcetype=rexmemtotal | rex field=_raw "(MemTotal:\s+(?P<rexmemtotal>\d+))" | table rexmemtotal _raw
Try this
... | rex (?P<MemTotal>(?<=MemTotal\:\s)\d+(?=\s\w{2}))
What would this look like if I were to plug it into the field extractor tool?
Like this
(?P<MemTotal>(?<=MemTotal\:\s)\d+(?=\s\w{2}))
Still nothing, unfortunately.
If it helps, the amount of whitespace and the number of integers will vary between records.
Ahh yeah the amount of whitespace mattered, but this should work
(?P<MemTotal>MemTotal\:\s+(?<MemoryTotal>[^\s]+))
Try "MemTotal: (?<memTotal>\d+)"
.
No dice. It didn't extract anything.
Did you use it in a rex
command?
No. I'm trying to use the field extractor because the info is for a non-dev unit