473,804 Members | 3,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extracting a string from a string

hi.

I do want to extract this string "abcdefg" from string
"C:\dir1\dir2\a bcdefg-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 1808
Per Juul Larsen wrote:
hi.

I do want to extract this string "abcdefg" from string
"C:\dir1\dir2\a bcdefg-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\a bcdefg-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\a bcdefg-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
6956
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 some part of it like all names or numbers from each line, simply text fom between e.g. second and third colon. And turn it
2
3660
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
3000
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, GAMESS=/opt/gamess,GAUSS_ARCHDIR=/opt/g03b05/g03/arch, GAUSS_EXEDIR=/opt/g03b05/g03/bsd:/opt/g03b05/g03/private:/opt/g03b05/g
2
2819
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 C#. The only significant problem that I have encountered in the conversion is this one - extracting an icon from the 'KTEntryPoint' program into the software suite and placing that icon on the PC Desktop.
13
3742
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 these methods EXTRACT the data at one point or another. The other problem is there appears to be NO WAY to get at the actual buffer pointer (char*) of the characters in the stream. There is a way to get the streambuf object associated with the...
7
3083
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 in advanced for any and all help. Thank you. <span class="sale"> $14.99 </span>, <span class="sale">
2
4162
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 source codes I'm going to post it here as I did a search here and did not find any question related to mine. I'm doing an automatic inventory control system using RFID project and I'm instructed to extract the RFID transponder's ID and CRC and display...
6
4458
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 some one experience with other libaries to
4
3960
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 occurs a number of times, but not an exact match for the string above. Can you help please: see code #!C:\\Perl\\bin use File::Copy; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); ...
5
3649
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 strDetails foreach(string str in strDetails) { //Code comes here }
0
10564
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.