Python Forum
can not change double to single dash
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can not change double to single dash
#2
Please put your code in the [python][/python] markers or all the indentation is lost...

Notice that your statement (the syntax highlighting does not like your profuse use of the backslash...)
>>> "\\".replace("\\\\","\\")
'\\'
is equivalent to:
>>> "A".replace("AA", "A")
'A'
And there is obvious that in a string of 1 char there will be 0 replacements of a 2 chars group.
Your expression works when the input has 2 or more backslashes:
>>> bs = '\\'
>>> s = bs * 8
>>> s
'\\\\\\\\\\\\\\\\'
>>> len(s)
8
>>> s.replace("\\\\", "\\")
'\\\\\\\\'
>>> len(_)
4
Reply


Messages In This Thread
can not change double to single dash - by oco - May-27-2018, 08:40 AM
RE: can not change double to single dash - by killerrex - May-27-2018, 09:22 AM
RE: can not change double to single dash - by oco - May-29-2018, 06:38 AM
RE: can not change double to single dash - by wavic - May-29-2018, 06:51 AM
RE: can not change double to single dash - by oco - May-30-2018, 07:09 AM
RE: can not change double to single dash - by wavic - May-30-2018, 07:26 AM
RE: can not change double to single dash - by oco - Jun-03-2018, 08:08 AM
RE: can not change double to single dash - by wavic - Jun-03-2018, 09:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 7,072 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Single digits seem to be greater than double digits Frosty_GM 4 3,590 Nov-20-2020, 10:13 AM
Last Post: DeaD_EyE
  create loop of subplot plotly dash without hardcode tonycat 0 3,961 Sep-23-2020, 08:40 AM
Last Post: tonycat
  How to update component props every time when a Dash callback returns? sguzunov 0 2,591 Jul-27-2020, 07:11 AM
Last Post: sguzunov
  Invalid archive error when attempting to install dash bootstrap components meaydemi 0 4,810 Jul-11-2019, 05:49 PM
Last Post: meaydemi
  how to use dataframe in dash? zhujp98 1 2,883 Jun-20-2018, 12:19 AM
Last Post: scidam
  dash problems zhujp98 0 2,274 Jun-14-2018, 03:30 PM
Last Post: zhujp98
  Change single element in 2D list changes every 1D element AceScottie 9 12,181 Nov-13-2017, 07:05 PM
Last Post: Larz60+
  Replace Single Backslash with Double Backslash in python saswatidas437 2 33,535 Mar-19-2017, 10:48 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020