Create your first automation in just a few minutes.Try Studio Web →
by YouTube
2
Snippet
<100
Summary
Summary
Find Sequence in String and Compare Against Array
Overview
Overview
Find a sequence in a string.
If you're looking for a particular sequence within a string and checking to see if it exists in an array then use this. Currently what this code does is to turn a string into a char array and turns the original array you're checking against into a dictionary. It loops through the char array looking for a sequence of 3 characters between 2 special characters (including whitespace) so some like this: (USD). It then checks to see if that sequence is a key in the dictionary and returns true / breaks the loop if it's found. It does not include the special characters when checking against the dictionary. So change fboName to whatever string you want to check, currencyCodes to whatever array you want to check against, and Char.IsLetterOrDigit to whatever you want to parse the char array by (i.e. maybe you just want to find letters or digits instead of special characters).
Since I'm looking for 3 characters I put a check(index versus the length of the array) in the if statement to make sure I wouldn't get an index out of range exception, you'll have to change this if you're looking for a different amount of characters.
Features
Features
Being able to find a particular sequence within a string. For example, if you want to find the sequence EUR in a string such as Example Fuel EUR-A then it will search the string looking for two special characters separated by three characters and check that result against a dictionary. Things like The European Fuel Company will return false as it does not find the special characters to the right and left of EUR but The European Fuel Company EUR-A will return true. This helps if you're trying to find multiple different sequences as you can house the different values in the dictionary so that the code can find something like Example Fuel EUR-A and Example Fuel USD-A since both EUR and USD are currency codes in array that get put in the dictionary. These are just examples so that it is easier to follow, you can switch it to anything.
Additional Information
Additional Information
Dependencies
Microsoft Activities
Code Language
Visual Basic
License & Privacy
Apache
Privacy Terms
Technical
Version
1.0Updated
February 18, 2020Works with
2018.2.3 and above, have not tested below
Certification
Silver Certified
Support
UiPath Community Support