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

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 2013-03-19 15:52 +0000
Organization Norwich University
Message-ID <aqrfu9F1v84U2@mid.individual.net> (permalink)
References <mailman.3521.1363707421.2939.python-list@python.org>

Show all headers | 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