I've got a string that will look like this:
zzz='hello',kkk='goodbye',jpjh='zz7t8d8',mary='Tha nk
You',jane='idontwantthis',somethingelse='nothinghe re'
It will have undefined number comma seperated tokens.
I want to write a VB function that when passed a matching left side
identifier, returns it's assigned value. If none match, returns "Error
No Match"
so myfunction("mary") should return "Thank You"
Thanks for any help or information! 5 1180
On Feb 26, 12:13 pm, "jobs" <j...@webdos.comwrote:
I've got a string that will look like this:
zzz='hello',kkk='goodbye',jpjh='zz7t8d8',mary='Tha nk
You',jane='idontwantthis',somethingelse='nothinghe re'
It will have undefined number comma seperated tokens.
I want to write a VB function that when passed a matching left side
identifier, returns it's assigned value. If none match, returns "Error
No Match"
so myfunction("mary") should return "Thank You"
Thanks for any help or information!
hmmm you could split the string based on the comma, then go through
each item that results from the split and split again on the "=". You
could use these splits to build a hash table where the left side of
"=" is the key and the right side is the value.
Then your function would take the key, look it up in the hash table
and return the value.
jobs wrote:
I've got a string that will look like this:
zzz='hello',kkk='goodbye',jpjh='zz7t8d8',mary='Tha nk
You',jane='idontwantthis',somethingelse='nothinghe re'
It will have undefined number comma seperated tokens.
I want to write a VB function that when passed a matching left side
identifier, returns it's assigned value. If none match, returns "Error
No Match"
so myfunction("mary") should return "Thank You"
Thanks for any help or information!
I would create a regular expression from the identifier. The identifier
"mary" would give the regular expression "(?:^|,)mary='([^']*)'".
Dim data As String =
"zzz='hello',kkk='goodbye',jpjh='zz7t8d8',mary='Th ank
You',jane='idontwantthis',somethingelse='nothinghe re'"
Dim identifier As String = "mary"
Dim pattern As String = "(?:^|,)" & Regex.Escape(identifier) & "='([^']*)'"
Dim match As Match = Regex.Match(data, pattern)
Dim value As String
If match.Groups.Count = 2 Then
value = match.Groups(1).Value
Else
value = "Error No Match"
End If
--
Göran Andersson
_____ http://www.guffa.com
Thank you that's perfect!
hi.
sorry, my requirements are slightly different than expected. Not sure
if the spaces or special characters are the problem, but I need it
find identifiers like this as well:
Filename = 'd:\jcp\hellocpm.txt', Filename2 = 'd:\jcp\hellocpm.txt'
its reporting match group = 1 and not 2.
Thanks.
On Feb 26, 3:30 pm, "jobs" <j...@webdos.comwrote:
hi.
sorry, my requirements are slightly different than expected. Not sure
if the spaces or special characters are the problem, but I need it
find identifiers like this as well:
Filename = 'd:\jcp\hellocpm.txt', Filename2 = 'd:\jcp\hellocpm.txt'
its reporting match group = 1 and not 2.
Thanks.
please disregard this.. I figured it out. thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vaca Louca |
last post by:
Hello,
My setup: Debian sarge on dual Pentium 4. g++ 3.3.5-3.
(the other system is Windows XP with MS Visual Studio .NET 2003)
I have an auto_array<T> template (based on a template taken from...
|
by: JackM |
last post by:
I'm trying to write a function that will trim and strip new line
character returns from submitted $_POST values. Does this look serviceable?
function trim_data($formdata)
{
foreach ($formdata...
|
by: Lauren Wilson |
last post by:
Hi folks,
We have a need to replace sub strings in certain message text. We use
the Office Assistant to display help and often use the imbedded
formatting commands. Those of you who have used...
|
by: KevinGPO |
last post by:
I am wondering about what's the best and easiest way to strip trailing
whitespace from every single file in a folder, recursively.
I want to write a program/script so that you pass in a folder...
|
by: Martin Jørgensen |
last post by:
Hi,
Short question:
Any particular reason for why I'm getting a warning here:
(cast from function call of type int to non-matching type double)
xdouble = (double)rand()/(double)RAND_MAX;
| |
by: bratiskovci |
last post by:
1. How do I change the program so that the program does not terminate after completing one conversion. Instead, the program should continue to convert values until the user indicates that he/she...
|
by: wkerplunk |
last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck.
When you click on an item in the dropdown autocomplete div it does a mousedown function...
|
by: idoerg |
last post by:
Hi all,
I am running Python 2.5 on Feisty Ubuntu. I came across some code that
is substantially slower when in a method than in a function.
################# START SOURCE #############
# The...
|
by: adamjblakey |
last post by:
Hi,
I have the following function which does not strip everything i need.
function StripAll($value) {
$value = preg_replace('/+/', '', $value);
$value =...
|
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,...
|
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...
| |
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: 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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |