Pete,
Why do you have to use a regular _expression_?
I don't, I just though this was the easiest way.
> "DcaVer"=dword:00000640
Is all your other input pretty much identical in form? Specifically,
the number of interest is the last thing on the line, and always
preceded by a colon?
> "DcaVer"=dword:00000640
Is all your other input pretty much identical in form? Specifically,
the number of interest is the last thing on the line, and always
preceded by a colon?
The other information is pretty much identical in form, yes. Exactally, all I am interested in is the number following the colon.
> What I need to do with that string is trim down " "DcaVer"=dword:" and
> convert the remaining number from hex to dec.
What does "trim down" mean? Do you need something out of the string, or
are you just discarding/ignoring it?
What I meant was I want to discard the "DcaVer"=dword: . All I am interested in is searching for "DcaVer, finding it, and then taking the numerical value found after the colon.
s = '"DcaVer"=dword:00000640'
value = int(s.split(':')[-1], 16)
(In other words, split on colons, take the last field and, treating it
as a hex value, convert to an integer.)
s = '"DcaVer"=dword:00000640'
value = int(s.split(':')[-1], 16)
(In other words, split on colons, take the last field and, treating it
as a hex value, convert to an integer.)
The only problem with this is DcaVer's value is not always going to be the same, so I need to search specially for DcaVer and then after finding it get the numerical value associated with it.
Thanks
-- http://mail.python.org/mailman/listinfo/python-list