473,513 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tokenizing

I'm trying to extract the key/value pairs string like this:

[Status]
CurrTime = 1200
LastPlayQUpdate = 400
CurrVolume = -10
[End Status]

My first instinct is to use a regular expression to match values before and
after the '=', but there probably is a more efficient method.

Can anyone suggest a better approach?

Thanks,

Craig Buchanan
Jun 13 '06 #1
3 1073

Dim strPairs() As String = Split(line, "=")

You could load the text file (I guess i am assuming this is where the
data is from) line by line and extract the pairs.

Craig Buchanan wrote:
I'm trying to extract the key/value pairs string like this:

[Status]
CurrTime = 1200
LastPlayQUpdate = 400
CurrVolume = -10
[End Status]

My first instinct is to use a regular expression to match values before and
after the '=', but there probably is a more efficient method.

Can anyone suggest a better approach?

Thanks,

Craig Buchanan


Jun 13 '06 #2
Hello Craig,

This is an INI file. Use DllImport ('Declare' keyword in VB) to import
GetPrivateProfileString from Kernel32.dll.
In fact there are several GetPrivateProfile* functions.

http://msdn.microsoft.com/library/de...filestring.asp
-Boo

I'm trying to extract the key/value pairs string like this:

[Status]
CurrTime = 1200
LastPlayQUpdate = 400
CurrVolume = -10
[End Status]
My first instinct is to use a regular expression to match values
before and after the '=', but there probably is a more efficient
method.

Can anyone suggest a better approach?

Thanks,

Craig Buchanan

Jun 13 '06 #3
Craig,

As alternative from Charlie,

You can just use the string.lastindex of method (although in this sampe the
standard indexoff method goes as well to) to get the starting point for a
string.substring.)

http://msdn.microsoft.com/library/de...exoftopic2.asp

http://msdn.microsoft.com/library/de...ringtopic1.asp

Alternatively you can use as well the Find and the Mid

I hope this helps,

Cor
"Craig Buchanan" <so*****@microsoft.com> schreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
I'm trying to extract the key/value pairs string like this:

[Status]
CurrTime = 1200
LastPlayQUpdate = 400
CurrVolume = -10
[End Status]

My first instinct is to use a regular expression to match values before
and after the '=', but there probably is a more efficient method.

Can anyone suggest a better approach?

Thanks,

Craig Buchanan

Jun 13 '06 #4

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

Similar topics

2
2100
by: Steve | last post by:
I'm writing a snippet of code intended to parse a grid that is represented by a long string. Each row of the grid is deliminated in the string with a '~' character. Inside each row substring,...
0
829
by: Ehsan Sadeghi | last post by:
Hello what is the best way to get access to each word in a document. i mean for example if you have a file (text,dat, binary...) after you open the file and get the document from it how can you...
0
738
by: Ehsan Sadeghi | last post by:
Hello what is the best way to get access to each word in a document. i mean for example if you have a file (text,dat, binary...) after you open the file and get the document from it how can you...
3
9569
by: Christian O'Connell | last post by:
Hello - in Java you have a class called java.util.StringTokenizer that tokenizes strings, ie StringTokenizer st=new StringTokenizer("In the beginning "," ",false); while (st.next())...
11
3917
by: wreckingcru | last post by:
I'm trying to tokenize a C++ string with the following code: #include <iostream> #include <stdio> #include <string> using namespace std; int main(int argc, char* argv)
8
2155
by: Acolyte | last post by:
Ok, the program I'm working on now involves taking an input string and tokenizing it, by seperating it by spaces. Here's what I've got: #include <stdio.h> #include <string.h> int main (void) {...
4
1410
by: dhirenved | last post by:
hi, i have to use string tokenizing to isolate commands and the arguments that i have to execute using the execvp command. here is what i'm using char* token; char buf; printf("enter command");...
0
7267
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
7391
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,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5697
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,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1609
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 ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
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...

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.