• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Replace the punctuality

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I have a list of the sentence and some of the words are split by a slash and when I am removing punctuality it removes all the slash but does not create space between those words.

What do I need to do?

 lyrics = "Sing, sing a song/Let the world sing along/" +
       "Sing of love there could be/Sing for you and for me/" +
       "Sing, sing a song/Make it simple to last/" +
       "Your whole life long/Don't worry that it's not/" +
       "Good enough for anyone/Else to hear/" +
       "Just sing, sing a song";




Output;
lastyour
whole
life
longdont
worry
that
its
notgood
enough
for
anyoneelse
 
Saloon Keeper
Posts: 23729
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Punctuality refers to time (promptness). What you are asking about is punctuation.

The slash is not considered as ordinary punctuation, but it is often used, as it is here, to separate stanzas in structured text. If you wish to replace them, the best choice for replacement is to substitute an end-of-line for the slash. Although since you are actually just trying to extract words, you could also replace the slash with a space.

One caution about general use - the slash is also commonly used in English to indicate options. For example, to say "a and/or b", since English doesn't otherwise distinguish between "inclusive-or" and "exclusive-or". So swapping spaces for slashes is OK, but if I was to submits something like this:


In Spring/Summer when I feel the breezes/of the soft Gulfstream shores/I sigh with contentment/and ponder the sharks in the sea.

That would be a bit trickier to break into lines!
 
Master Rancher
Posts: 3899
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tomy Alexsander wrote:when I am removing punctuality it removes all the slash but does not create space between those words.




That is because here, you are telling it to replace all punctuation with... nothing:

The "" represents an empty string, with nothing in it, including no space.

If you want to replace with something, like a space:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic