473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

extracting a string from a string

hi.

I do want to extract this string "abcdefg" from string
"C:\dir1\dir2\abcdefg-12345gsd"
Note : the length of the text string "abcdefg" may vary, but the last
character is always "-".
I need only the string "abcdefg" not "-12345gsd"

thanks pjl Denmark
Jul 11 '08 #1
2 1783
Per Juul Larsen wrote:
hi.

I do want to extract this string "abcdefg" from string
"C:\dir1\dir2\abcdefg-12345gsd"
Note : the length of the text string "abcdefg" may vary, but the last
character is always "-".
I need only the string "abcdefg" not "-12345gsd"

thanks pjl Denmark
Assuming you're using VB6...

Dim s As String
Dim n As Integer

s = "C:\dir1\dir2\abcdefg-12345gsd"
Debug.Print s

n = InStrRev(s, "\")
If n 0 Then
s = Mid$(s, n + 1)
Debug.Print s
End If

n = InStr(s, "-")
If n 0 Then
s = Left$(s, n - 1)
End If
Debug.Print s

Easy, wasn't it?
Jul 12 '08 #2
Jason Keats skrev:
Per Juul Larsen wrote:
>hi.

I do want to extract this string "abcdefg" from string
"C:\dir1\dir2\abcdefg-12345gsd"

Note : the length of the text string "abcdefg" may vary, but the
last character is always "-".
I need only the string "abcdefg" not "-12345gsd"

thanks pjl Denmark

Assuming you're using VB6...

Dim s As String
Dim n As Integer

s = "C:\dir1\dir2\abcdefg-12345gsd"
Debug.Print s

n = InStrRev(s, "\")
If n 0 Then
s = Mid$(s, n + 1)
Debug.Print s
End If

n = InStr(s, "-")
If n 0 Then
s = Left$(s, n - 1)
End If
Debug.Print s

Easy, wasn't it?
That Easy.. thanks
regards pjl
Jul 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lecichy | last post by:
Hello Heres the situation: I got a file with lines like: name:second_name:somenumber:otherinfo etc with different values between colons ( just like passwd file) What I want is to extract...
2
by: Sammy | last post by:
Subject line says it all really. I have a 4 character long string, that contains a 32bit integer. Problem is i have no idea how i go about extracting it. Any help will be appreciated.
2
by: Steve | last post by:
Hi, I have a very long string, someting like: DISPLAY=localhost:0.0,FORT_BUFFERED=true, F_ERROPT1=271\,271\,2\,1\,2\,2\,2\,2,G03BASIS=/opt/g03b05/g03/basis,...
2
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
13
by: Randy | last post by:
Is there any way to do this? I've tried tellg() followed by seekg(), inserting the stream buffer to an ostringstream (ala os << is.rdbuf()), read(), and having no luck. The problem is, all of...
7
by: Tempo | last post by:
Hello. I am having a little trouble extracting text from a string. The string that I am dealing with is pasted below, and I want to extract the prices that are contained in the string below. Thanks...
2
by: VictorTan | last post by:
Hello. I'm new to this forum. Hope that I don't make mistakes in here but if I do, please correct me if there is. Thanks. I also wanted to ask you guys regarding about the following following...
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
4
by: dexter48 | last post by:
Hi I'm searching for a string occurance in a text file. I find the string ok and write the results to a log file. But on the line above is also some information I need. How can i get that. The string...
5
by: Mukesh | last post by:
Hi, I am using framework 2.0. I am writing a foreach loop that will extract single dimensional arrays out of double dimensional array. I am trying writing something like this. string ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.