Python Forum
Matching whole words in find/replace script
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matching whole words in find/replace script
#2
What exactly do you want to achieve? Matching a whole word or replace one with another.
with open('C:/Temp/Substitutions.txt') as f:
    for line in f:
        if word in line.lower(): # lower is an option here if you want case insensitive matching 
            # do something
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: Matching whole words in find/replace script - by wavic - Jul-10-2017, 08:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  find and group similar words with re? cartonics 4 813 Oct-27-2023, 05:36 PM
Last Post: deanhystad
  package script cant find sibling script when executed from outside Bock 3 947 Mar-03-2023, 04:26 PM
Last Post: snippsat
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 1,640 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
  Find and Replace numbers in String giddyhead 2 1,290 Jul-17-2022, 06:22 PM
Last Post: giddyhead
  Regular Expression for matching words xinyulon 1 2,218 Mar-09-2022, 10:34 PM
Last Post: snippsat
  Generate a string of words for multiple lists of words in txt files in order. AnicraftPlayz 2 2,882 Aug-11-2021, 03:45 PM
Last Post: jamesaarr
  Find and replace in files with regex and Python Melcu54 0 1,874 Jun-03-2021, 09:33 AM
Last Post: Melcu54
  find an replace not in all entries Monsterherz 1 1,974 Mar-01-2021, 03:59 PM
Last Post: BashBedlam
  Trying to find first 2 letter word in a list of words Oldman45 7 3,844 Aug-11-2020, 08:59 AM
Last Post: Oldman45
  Find and replace to capitalize with Regex hermobot 2 2,568 Mar-21-2020, 12:30 PM
Last Post: hermobot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020