Help With pattern matching - c#-2.0

In my code I have to match below 3 types of data
abcd:xyz:def
def:xyz
xyz:def
where "xyz" is the real data and other part are Junk data. Now, for first 2 types as below I can split with ':' and can get the array[1] position data ... which will give me the correct one.
abcd:xyz:def
def:xyz
I am not getting How can extract the 3rd case. Any idea? Please help.
Thanks,
Rahul

string case1 = "abcd:xyz:def";
string case2 = "def:xyz";
string case3 = "xyz:def";
string result1 = case1.Split(':')[1];
string result2 = case2.Split(':')[1];
string result3 = case3.Split(':')[0];
If I understand your question correctly.

Use array[0] instead of array[1] in the third case after splitting.

Related

How to use a String in a List dart?

How to turn a String into a List in Dart? I'm sharing some code to let you know what I want to achieve.
String testString = "'banana', 'apple', 'peach'";
List testList = [testString];
print(testList); // This is where I want to get 'banana' instead I get the whole String back.
Thanks in advance
I think split method is what you need.
it will split the string at matches of pattern and returns a list of substrings.
String testString = "banana,apple,peach";
List testList = testString.split(',');
print(testList);
check out this link for more info.

How to get DataGridView cell value?

I need to compare my array string with DataGridView cell value
string z = DataGridView->Rows[e->RowIndex]->Cells[1]->Value.ToString();
I'm getting a problem:
IntelliSense: expression must have class type
I figured out the answer if anyone else needs solution here it is
String^ z = System::Convert::ToString(Grid_Darbuotojai->Rows[e->RowIndex]->Cells[1]->Value);

Insert variable | Data base | AT commands | SIM900

I trying to send data temperature from Arduino to data base... I've finished the connection, but I need replace a part of String, that is the static URL:
SIM900.println("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=-127.7&Temperatura_Action=Insert\"");
and this is my variable:
float = tmp;
tmp = sensor.getTempCByIndex(0);
And the URL I need replace the "-127.7" for the variable... but remember, the URL it's a String. I hope you can help me, thanks!
I don't use Arduino very much, but maybe this could help:
http://playground.arduino.cc/Main/FloatToString
https://www.arduino.cc/en/Tutorial/StringAdditionOperator
I got the solution...
This is my URL
SIM900.println("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=-127.7&Temperatura_Action=Insert\"");
and the parameter to replace is the "-127.7"
I divided the URL on two parts into Strings...
String stringvar = String(tmp);
String stringurl1 = String("AT+HTTPPARA=\"URL\",\"http://mail.interseccion.com.mx:8901/dbTemperatura?Id_temp=0&Id_Device=1&Valor=);
String stringurl2 = String("&Temperatura_Action=Insert\"");
String urlfinal = String(String(url1) + String(strinvar) + String(stringurl2));
For anyone has the same kind url...

How can I convert a string to a char array in ActionScript 3?

How do you convert a string into a char array in ActionScript 3.0?
I tried the below code but I get an error:
var temp:ByteArray = new ByteArray();
temp = input.toCharArray();
From the error, I understand that the toCharArray() function cannot be applied to a string (i.e in my case - input). Please help me out. I am a beginner.
I am not sure if this helps your purpose but you can use String#split():
If you use an empty string ("") as a delimiter, each character in the string is placed as an element in the array.
var array:Array = "split".split("");
Now you can get individual elements using index
array[0] == 's' ; array[1] == 'p' ....
Depending on what you need to do with it, the individual characters can also be accessed with string.charAt(index), without splitting them into an array.

F# GetDigitValue value or construct not valid

I am new to F# and would like to have an advice.
I would like to use the GetDigitValue function.
open System
open System.Drawing
open System.Globalization
let getSubscript ichar =
match ichar with
|1 -> GetDigitValue(843)
| _ -> GetDigitVale(852)
I have the following error: The value or constructor 'getDigitValue" is not defined.
Without further information I can't really tell what you are trying to do.
GetDigitValue is a static method of the CharUnicodeInfo class.
It is used like this:
let testString = "1234567890"
let digitValue = CharUnicodeInfo.GetDigitValue(testString, 3)
This returns the digit value for the 3rd character in the string. It also works with a single character too.
let test = '5'
let digitvalue = CharUnicodeInfo.GetDigitValue(test)
Update:
To get the superscript of a string I think the Numeric value will return this:
let superscriptTwo ="U+00B2"
let numericvalue = CharUnicodeInfo.GetNumericValue(superscriptTwo)
I would like to get the superscript of numbers.
Then I think you want this function that gives a unicode character that is the superscript of the given digit:
let superscriptOf n =
if 0<=n && n<10 then "⁰¹²³⁴⁵⁶⁷⁸⁹".[n] else
invalidArg "n" "Not a single digit number"
Note that F# supports unicode in F# code. You can even use unicode variable names like λ in F# code!

Resources