Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:44:59+00:00 2026-05-25T20:44:59+00:00

I want to search several words at the same time in a text file.

  • 0

I want to search several words at the same time in a text file.

For example think I want to search these 3 words: Majid,superuser,device

Normally I should search for them one by one, and I can not search all of them at the same time. So I want to search these words at the same time in a text file.

I want to enter those 3 words in a text file, one word per line. Let’s name it SearchText. Now I have a Target Text which I want to search those words in it. Let’s name it TargetText.

I want to tell an app or something similar to get words from SearchText and find them in TargetText and Highlights them or gives me the find result.

I hope I’m clear. So can anyone hep me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:45:00+00:00Added an answer on May 25, 2026 at 8:45 pm

    You’re clear. I think the best option would be Regex.

    Try this:

    Option Explicit
    Dim oFso        : Set oFso = CreateObject("Scripting.FileSystemObject")
    Dim srcPath     : SrcPath = oFso.GetParentFolderName(WScript.ScriptFullName)
    Dim sWordList   : sWordList = ofso.OpenTextFile(oFso.BuildPath(srcPath, "search.txt")).ReadAll()
    Dim sTargFile   : sTargFile = ofso.OpenTextFile(oFso.BuildPath(srcPath, "target.txt")).ReadAll()
    Dim strWords    : strWords = Join(Split(sWordList, vbCrLf), "|")
    Dim oReg        : Set oReg = New RegExp
    Dim oDict       : Set oDict = CreateObject("Scripting.Dictionary") 'for found words
    oDict.CompareMode = vbTextCompare 'case insensitive
    
    With oReg
        .Global = True
        .IgnoreCase = True
        .Pattern = "("& strWords &")" ' (word1|word2|word3|etc..)
        'if the words contain some special chars for regex, you may need to escape with \ char
        'see the information below: http://goo.gl/cqGVp
        Dim collFND : Set collFND = oReg.Execute(sTargFile)
        Dim Fnd
        'WScript.Echo String(50, "-")
        For Each Fnd In collFND
            With Fnd
                'WScript.Echo "Word : "& .Value, ", Position: ("& .FirstIndex &","& .Length &")"
                oDict(.Value) = ""
            End With
        Next
        Set collFND = Nothing
        'WScript.Echo String(50, "-"), vbCrLf, "Higlighted Output:", oReg.Replace(sTargFile, "[$1]")
        ofso.CreateTextFile(oFso.BuildPath(srcPath, "foundwords.txt"),True).Write(Join(oDict.Keys, vbCrLf)) 'found words saved
    End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to search a text in a table without knowing its attributes. Example
We want to search a file to find all instances of bar that are
I want to search through a html file and then get the url to
I want to search a php file to find all calls to a functions
I use codeigniter.I want search in site contents for several word, that did existence
I have several views where I want the search bar to be hidden unless
I search for a good way to copy a file (binary or text). I've
I want to search two item (name=string and location=json). this search is (one input
I want to search a series of files based on the files name. Here
I want to search a user from LDAP and after getting the user I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.