En Thu, 08 Apr 2010 12:26:56 -0300, Booter <colo.av...@gmail.com> escribió:
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
***************************Statement************************************
capture = re.sub('\.*', '\b', capture)
The * means "ZERO or more" occurrences - matching practically everywhere.
I think you want \.+ -- one or more occurrences of a literal period. To
actually have a \ in the string, you have to write it as "\\.+" or r"\.+"
===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
==============================END============================
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...
You want those \b, don't you? Just not everywhere...
===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 ...
==============END================================
Except for the last '...' I don't see any '.' in that string to be
replaced...
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list