Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41527

Re: Replace "dash" values in a field with new line- VB equivalent of Python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!telefonica.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Neil Cerutti <neilc@norwich.edu>
Newsgroups comp.lang.python
Subject Re: Replace "dash" values in a field with new line- VB equivalent of Python
Date 19 Mar 2013 15:52:41 GMT
Organization Norwich University
Lines 30
Message-ID <aqrfu9F1v84U2@mid.individual.net> (permalink)
References <mailman.3521.1363707421.2939.python-list@python.org>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace individual.net N21d3smXhSeJBG3dt1S+OQqD0mWk0fkbWNdEA2LfDoIWUgHUpp
Cancel-Lock sha1:Wix+78al3DU85BC5+iS/Bstn1mo=
User-Agent slrn/0.9.9p1/mm/ao (Win32)
Xref csiph.com comp.lang.python:41527

Show key headers only | View raw


On 2013-03-19, Cathy James <nambo4jb@gmail.com> wrote:
> Dear All,
> I need some assistance with Python so that values in the "Name"
> field e.g. Murray - James - Leo can be labeled as:
>
> Murray
> James
> Leo
>
> with a new line replacing every dash.
>
> Basically I need the equivalent of this VB in Python:
> replace ( [Name]  , "-", vbNewLine)
>
> I tried this but no luck:
>
> str.[Name].replace("-", "\n")
> str.[Name].replace("-", \n)
> [Name].replace("-", \n")

str methods return new strings in Python, so you need to bind
something to them.

I don't know what the VB syntax above means, but if I pretend
that your string is bound to 'Name':

Name = Name.replace(" - ", "\n")

-- 
Neil Cerutti

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Replace "dash" values in a field with new line- VB equivalent of Python Cathy James <nambo4jb@gmail.com> - 2013-03-19 11:36 -0400
  Re: Replace "dash" values in a field with new line- VB equivalent of Python Neil Cerutti <neilc@norwich.edu> - 2013-03-19 15:52 +0000
  Re: Replace "dash" values in a field with new line- VB equivalent of Python rusi <rustompmody@gmail.com> - 2013-03-19 08:59 -0700

csiph-web