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 6803651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:22:13+00:00 2026-05-26T19:22:13+00:00

I am trying to build an application which does the following : 1) write

  • 0

I am trying to build an application which does the following :

1) write some text in a richtextbox


2) when user clicks a button, the app will replace the text with another text in {} braces.

what I want is that the next time, the regex searches for any text it should exclude those which are present in {}.

for eg :

my world is good world and a happy world and will be a better world for everyone.

first pass – change word “world”

my {world|happy place|home} is good {world|happy place|home} and a happy {world|happy place|home} and will be a better {world|happy place|home} for everyone.

second pass – change word “happy”

in this pass I want the regex to ignore all instances which are surrounded by {}. notice word happy comes in {world|happy place|home}, but it should not be touched.

now could anyone please help me with building this regex?

In simple terms I want to include the word and exclude everything that falls between {}. Also please note that word can be a string.

for eg : sometimes I might want to replace the string “happy place”.

any other logic other than regex can also help.

my code is :

Dim fil2 As New StreamReader("new2.txt")

    Dim i As Integer = 0
    Dim start2 As Integer = 0
    Dim rgx As Regex

    Dim rpl As String = RichTextBox1.Text

    Do While fil2.Peek > -1
        Dim StringToCheck As String = fil2.ReadLine()
        Dim prev As String = StringToCheck.Split("|")(0).Trim()

        If (StringToCheck.Split("|")(0).Split(" ").Count >= 2) Then
            Try
                rgx = New Regex("(?<=(^|})[^{]*)" & prev & "(?=[^}]*($|{))")
                Dim z As Integer = 0

                rpl = rgx.Replace(rpl, "{" & StringToCheck & "}")


            Catch ex As Exception

            End Try
        End If


    Loop

    fil2.Close()

    rpl = rpl.Replace("{?  ?|?  ?|? ! ?}", " ")
    RichTextBox1.Text = rpl
    MsgBox("done")
  • 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-26T19:22:14+00:00Added an answer on May 26, 2026 at 7:22 pm

    You can use lookaheads and lookbehinds:

    "(?<=(^|})[^{]*)happy(?=[^}]*($|{))"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build an application to simulate some basic spheres moving around.
I'm trying to build an application from source in windows that requires some Unix
I'm trying to build my application for GoogleAppEngine using maven. I've added the following
We are trying to build some RESTful services with Spring MVC. We will be
I'm trying to build a web application in which users can invite their friends
I'm trying to build a C# application, which uses Fiddler. I saw in the
I am trying to write a Django app which creates events in a specific
I'm currently trying to build an authentication application in Android which stores users' username
Can’t install application The application at /Users/myname/Documents/SDK/iPhoneApplications/x/build/Debug-iphoneos/x.app does not specify a CFBundleExecutable I don't
I'm trying to build an application starting from an Appfuse Archetype, but I get

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.