Regular Expressions
david brochu jr
brochu121 at gmail.com
Wed Apr 12 15:44:05 EDT 2006
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?*
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.)*
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060412/6591cdb8/attachment.html>
More information about the Python-list
mailing list