Discussion Board

Results 1 to 3 of 3

Thread: find in text

  1. #1
    Example

    txt = "Python is great and it is simple."
    txt.find("is")

    The output is 7 but how to find out the next "is" word?

    If there are many similar words, how to find them all?
    Last edited by DrivingMobileInnovation; 2008-06-07 at 00:58.

  2. #2
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    An improvised solution could be like this:
    Code:
    txt="Python is great and it is simple."  #The text in which to search
    
    word="is"  #The word to search for
    
    length=2  #The length of the word
    
    p=[]
    for i in range(len(txt)-length):
       if(txt[i:i+length]==word):p.append(i)  #Append the position to the list
    
    print p

  3. #3
    Nokia Developer Moderator croozeus's Avatar
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,635
    For core Python related issues, please refer to the documentation,

    http://docs.python.org/tut/tut.html

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

Similar Threads

  1. Replies: 13
    Last Post: 2008-01-04, 11:15
  2. Replies: 3
    Last Post: 2007-03-07, 03:36
  3. Rich Text Editor and Dialog
    By sakhya in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-04-28, 17:08
  4. Howto send LF in text mode SMS
    By Royessers in forum General Messaging
    Replies: 2
    Last Post: 2003-06-12, 09:47
  5. Append text
    By smlobo in forum Symbian User Interface
    Replies: 2
    Last Post: 2003-06-05, 03:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved