×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Replace triple quotes to single quote >> vb.net

Replace triple quotes to single quote >> vb.net

Replace triple quotes to single quote >> vb.net

(OP)
Hi -
In a small journal I'm playing around on how to replace some """ in a text file , which contains some words surrounding three quotes on each side of these words...
I want to remove two of the quotes on each side of all words in txt file ....
Ex. """MyName""" >>>> "MyName"

I need a little help on syntax ....
I have tried the Vb . Replace function, but seeems a little tricky because it is quotes..

Regard lklo

RE: Replace triple quotes to single quote >> vb.net

If you want the string variable to include literal double quote characters within the string, then simply assign the original value to a string variable:

CODE

dim myString as string = """MyName""" 
The value of the string variable will be: "MyName". This is useful if you want to create a string expression (see the "create a string expression" section of this article).

If you want to strip out the double quotes so that they do not appear in the string value, there are multiple ways to do it; below are two:

CODE

Option Strict Off
Imports System
Imports NXOpen

Module Module75

    Dim theSession As Session = Session.GetSession()
    Dim lw As ListingWindow = theSession.ListingWindow


    Sub Main()

        lw.Open()

        Dim strInput As String = """MyName"""
        lw.WriteLine("strInput: " & strInput)

        Dim strOutput As String
        strOutput = strInput.Replace("""", "")
        'chr(34) = "
        'alternatively, you can replace chr(34) with an empty string
        'strOutput = strInput.Replace(Chr(34), "")

        lw.WriteLine("strOutput: " & strOutput)

        lw.Close()
    End Sub

End Module 

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources