KavyaVS
asked on
Getting substring from the given string
I have a string variable with this value = <!--#include file="../search/SearchInfo .aspx" -->
Dim sName As String = "<!--#include file="../search/SearchInfo .aspx""
I am looping through the array,the page name keeps on changing.
I want this part "../search/SearchInfo.aspx " or just page name is also fine SearchInfo.aspx
How to get it.
Thanks
Dim sName As String = "<!--#include file="../search/SearchInfo
I am looping through the array,the page name keeps on changing.
I want this part "../search/SearchInfo.aspx
How to get it.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dim sName As String = "<!--#include file="../search/SearchInfo .aspx" -->"
It is returning SearchInfo.aspx" -->
But I want SearchInfo.aspx
Thanks
It is returning SearchInfo.aspx" -->
But I want SearchInfo.aspx
Thanks
Try something like that:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sName As String = "<!--#include file=""../search/SearchInfo.aspx""-->"""
' get substring and remove trailin quotes
Dim rawName As String = sName.Substring(sName.LastIndexOf("/"c) + 1)
Dim fileName As String = rawName.Substring(0, rawName.IndexOf(""""c))
MessageBox.Show(fileName)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I could able to get the file name.
Dim fileCont As String() = System.IO.File.ReadAllLine s(sFile)
I read the file by lines in string array.
How to get the part of the array between specific indexes(Ex:index 10 and 100)
Thanks
Dim fileCont As String() = System.IO.File.ReadAllLine
I read the file by lines in string array.
How to get the part of the array between specific indexes(Ex:index 10 and 100)
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will explain the requirement.
I read the .aspx file line by line in string array .It has include files in the body content. I replaced include files line with its content in string array. Now I want to get the content between body tags.
Do you have any other ideas? file content in the string array. Need to get the content inside the body tags to save it in database.
Thanks
I read the .aspx file line by line in string array .It has include files in the body content. I replaced include files line with its content in string array. Now I want to get the content between body tags.
Do you have any other ideas? file content in the string array. Need to get the content inside the body tags to save it in database.
Thanks
Honestly, I'm pretty confused. The initial task was to get a file name from a path string.
And I believe that the answer was given.
Now you are asking about the content. Can you explain with examples?
And I believe that the answer was given.
Now you are asking about the content. Can you explain with examples?
ASKER
Thanks
Dim sb As String = ""
If sa.Length = 3 Then
sb = sa(1)
Else
' Error
End If