2016-05-14 22:02:33

Hello all,
Is it possible to search through an array of strings using wildcards in bgt?
I'm creating a very basic parser, and I need to be able to find where things get placed. I've tried the array.find function, but the value needs to be static for that to work properly.
Thanks in advance everyone!

2016-05-14 23:48:54 (edited by sneak 2016-05-14 23:58:47)

If you mean how to search each entry in the array to see if it contains a phrase or character then yes there is.
I realized after posting that I should've commented this out to explain what I'm doing.
//This declares the array of type string called arrayString and gives it 5 empty entries.
string[] arrayString(5);
//The following 5 lines store a string within the array in a unique entry.
arrayString[0]="Hi my name is George.";
arrayString[1]="Hi my name is Alex.";
arrayString[2]="Hi my name is Diana.";
arrayString[3]="Hi my name is Bobbie";
arrayString[4]="Hi my name is Lewis";
//This creates a loop through arrayString and checks each entry for the characters 'diana', I don't recall if the string_contains function is case sensitive or not. It then returns the string that contains the text. You can manipulate this easily enough to return the location of the character in the string as well as the entire string.
for(int x=0; x<arrayString.length; x++)
{
if(-1<string_contains(arrayString[x], "Diana", 1))
{
return arrayString[x];
}
}
Hope this helps!

The universe is a rain storm. We are droplets sent to quench the problems of the world, yet we are blown sideways by the winds of distractions.

2016-05-15 04:11:22

hello,
This does work, and does partially solve the problem, however I completely forgot to mention I need to find the actual position in the array where the string is found, since that is what I am dealing with. Lol, its what happens when I write posts up in about 5 minutes, rofl.
Thanks for the reply sneak!

2016-05-15 04:35:12

Look at the help file in the bgt manual on string_contains.
Just change it to return string_contains(arrayString[x], "Diana");
That should return the position where the character set starts in the string.

The universe is a rain storm. We are droplets sent to quench the problems of the world, yet we are blown sideways by the winds of distractions.

2016-05-15 04:54:43

Hey,
Thanks for the quick reply!
I'm happy to say this is what I was looking for! Thanks a bunch sneak! smile

2016-05-15 07:19:37

Awesome! That's a huge confidence boost for me, knowing that I understand it enough to be able to give you exactly what you needed. big_smile Glad to help.

The universe is a rain storm. We are droplets sent to quench the problems of the world, yet we are blown sideways by the winds of distractions.