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

  • Home
  • SEARCH
  • 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 8691987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:13:53+00:00 2026-06-13T00:13:53+00:00

I have a large value on a String variable, I want to keep just

  • 0

I have a large value on a String variable, I want to keep just some of it, I don’t know the exact position in the String in which my data is located as it could vary any time, but I know it’s in between specific tags, so how could I keep only what’s inside those tags?

Example of the kind of string I have:

Dim var as String = "
<random>     <stuffIDontNeed>      <x>1</x>      <x>2</x>      <x>3</x>     
</stuffIDontNeed>     <stuffIDoNeed>      <x>a</x>      <x>b</x>      <x>c</x>   
</stuffIDoNeed>    </random> "

It’s all inside the same String I just used multiple lines so it showed fully without scrolling.

So what I want to do is to get everything from where stuffIDoNeed starts to where it ends, tags and everything not only the values in them.

  • 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-06-13T00:13:54+00:00Added an answer on June 13, 2026 at 12:13 am

    This will extract the substring from the input string (Please don’t use var as variable name, it is confusing)

    Dim inputData as String = " " & _
            "<random>     <stuffIDontNeed>      <x>1</x>      <x>2</x>      <x>3</x>      " & _
            "</stuffIDontNeed>     <stuffIDoNeed>      <x>a</x>      <x>b</x>      <x>c</x>   "  & _
            "</stuffIDoNeed>    </random> " 
    
    Dim result as string = string.Empty
    Dim startPos = inputData.IndexOf("<stuffIDoNeed>")
    Dim endPos = inputData.IndexOf("</stuffIDoNeed>")
    if startPos > 0 AndAlso endPos > 0 andAlso endPos > startPos then
        result = inputData.SubString(startPos, endPos + 15 - startPos)
    end if
    
    Console.WriteLine(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large set of values V, some of which are likely to
I have a variable actor which is a string and contains values like military
I have an integer value that spans a range so large it is impractical
i have a large mysql database table in which one column contains values ranging
I have Postcode in my large database, which contains values like SL5 9JH, LU1
I have this class in Java in which I declared a large number of
I have a code meant to strim a string within a large text file.
I would like to know whats faster. Help me out. I have a variable
I have a unit test that is used to test variable conversions from string
I have a method that retrieves data from a json serialized string and writes

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.