Replacing Periods with Backspaces

Booter colo.avs96 at
Thu Apr 8 11:26:56 EDT 2010


I am trying to replace a series of periods in a sting with backspaces
that way I can easily parse information from a Windows command.  the
current statement I have for this is

capture = re.sub('\.*', '\b', capture)

===Out Put===
str: \bi\bp\bc\bo\bn\bf\bi\bg\b \b/\ba\bl\bl\b\n\b\n\bW\bi\bn\bd\bo\bw
\bs\b \bI\bP\b \bC\bo\bn\bf\bi\bg\bu\br\ba\bt\bi\bo\bn\b\n\b\n\b \b \b
\bH\bo\bs\bt\b \bN\ba\bm\be\b \b \b \b \b \b \b \b \b \b \b \b \b \b:
\b \bT\br\bi\bt\bo\bn\b\n\b \b \b \bP\br\bi\bm\ba\br\by\b \bD\bn\bs\b
\bS\bu\bf\bf\bi\bx\b \b \b \b \b \b \b \b \b \b:\b \be\bn\bg\br\bC\bo
\bl\bo\bS\bt\ba\bt\be\bE\bD\bU\b\n\b \b \b \bN\bo\bd\be\b \bT\by\bp\be
\b \b \b \b \b \b \b \b \b \b \b \b \b \b:\b \bH\by\bb\br\bi\bd\b\n\b
\b \b \bI\bP\b \bR\bo\bu\bt\bi\bn\bg\b \bE\bn\ba\bb\bl\be\bd\b \b \b
\b \b \b \b \b \b:\b \bN\bo\b\n\b \b \b \bW\bI\bN\bS\b \bP\br\bo\bx\by
\b \bE\bn\ba\bb\bl\be\bd\b \b \b \b \b \b \b \b \b:\b \bN\bo\b\n\b \b
\b \bD\bN\bS\b \bS\bu\bf\bf\bi\bx\b \bS\be\ba\br\bc\bh\b \bL\bi\bs\bt
\b \b \b \b \b \b \b:\b \be\bn\bg\br\bC\bo\bl\bo\bS\bt\ba\bt\be\bE\bD
\bU\b\n\b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b
\b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \b \bC\bo\bl\bo\bS
\bt\ba\bt\be\bE\bD\bU\b\n\b\n\bE\bt\bh\be\br\bn\be\bt\b \ba\bd\ba\bp\bt
\be\br\b \bL\bo\bc\ba\bl\b \bA\br\be\ba\b \bC\bo\bn\bn\be\bc\bt\bi\bo
\bn\b:\b\n\b\n\b \b \b \bC\bo\bn\bn\be\bc\bt\bi\bo\bn\b-\bs\bp\be\bc\bi
\bf\bi\bc\b \bD\bN\bS\b \bS\bu\bf\bf\bi\bx\b \b \b \b:\b \b\n\b \b \b
\bD\be\bs\bc\br\bi\bp\bt\bi\bo\bn\b \b \b \b \b \b \b \b \b \b \b \b
\b:\b \bR\be\ba\bl\bt\be\bk\b \bP\bC\bI\be\b \bG\bB\bE\b \bF\ba\bm\bi
\bl\by\b \bC\bo\bn\bt\br\bo\bl\bl\be\br\b\n\b \b \b \bP\bh\by\bs\bi\bc
\ba\bl\b \bA\bd\bd\br\be\bs\bs\b \b \b \b \b \b \b...

which paces a bunch of '\b' strings throughout the string (to me at
random).  It sort of works if I use this command but I don't want
there to be whitespace...

capture = re.sub('\.*', '\b', capture)

===Out Put===
str: ipconfig /all\n\nWindows IP Configuration\n\n   Host
Name             : Triton\n   Primary Dns Suffix         :
engrColoStateEDU\n   Node Type             : Hybrid\n   IP Routing
Enabled        : No\n   WINS Proxy Enabled        : No\n   DNS Suffix
Search List      : engrColoStateEDU
\n                                       ColoStateEDU\n\nEthernet
adapter Local Area Connection:\n\n   Connection-specific DNS
Suffix   : \n   Description            : Realtek PCIe GBE Family
Controller\n   Physical Address         : 00-24-1D-16-FF-28\n   DHCP
Enabled           : No\n   Autoconfiguration Enabled     : Yes\n
IPv4 Address           : 12982227254(Preferred) \n   Subnet
Mask            : 2552552480\n   Default Gateway          :
129822241\n   DNS Servers            :
1298210378\n                                       1298210379\n
NetBIOS over Tcpip        : Enabled\n\nTunnel adapter
isatap{04FB4DF5-4B41-4058-A641-6965D13CCC06}:\n\n   Media
State            : Media disconnected\n   Connection-specific DNS
Suffix   ...

If anyone can help it would be greatly appreciated.


Gerad Bottorff

More information about the Python-list mailing list