Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 returns index of list if contains a word
#1
Hi,

how can i return index from the list if it contains special character + values?

example:

line1: [word1], [word2], [$300]

line2: [$4000], [word2], [word3]

How to return index when it starts with "$" to get from first line "$300" and from second line "$4000"?

Found answer:
import re


re.findall(r'[$]\w+', text)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to find something in a list using its index rix 1 99 Dec-20-2019, 04:12 PM
Last Post: stullis
  item = index position - list of list RavCOder 9 251 Dec-02-2019, 05:24 PM
Last Post: ThomasL
  IndexError: List index out of range issue Adem 1 479 Nov-01-2019, 10:47 PM
Last Post: ichabod801
  print a word after specific word search evilcode1 8 237 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  IndexError: list index out of range bug? CaptainCsaba 4 813 Oct-18-2019, 12:38 PM
Last Post: CaptainCsaba
  How do you replace a word after a match from a list of words in each line of a file? vijju56 1 279 Oct-17-2019, 03:04 PM
Last Post: baquerik
  Inspect.getmembers with isclass returns an empty list Aldar 1 168 Oct-02-2019, 01:48 PM
Last Post: Aldar
  List modification returns none Mark17 6 299 Sep-02-2019, 05:40 PM
Last Post: Mark17
  MAWS.py PRGM:IndexError: list index out of range bcramer 0 190 Aug-28-2019, 04:45 PM
Last Post: bcramer
  Select a part of an element of a list with Index BollerwagenIng 0 340 Aug-09-2019, 09:27 AM
Last Post: BollerwagenIng

Forum Jump:


Users browsing this thread: 1 Guest(s)