microsoft navision 2009, how to get the last nine characters - microsoft-dynamics

I have a string like this: Nl41ingb0006618174
And I want to return only the last nine characters.
I try it like this:
MyString := (IBAN);
MyString2.GETSUBTEXT(MyString, 1,TextPos-9);
MESSAGE(FORMAT(MyString2));
where IBAN = bank account number
MyString2 = bigtext
MyString = Text

You should do it via COPYSTR + STRLEN:
IF STRLEN(MyString) >= 9 THEN
MyString2 := COPYSTR(MyString,STRLEN(MyString)-8,9);

Related

How to check one string contains another sub string in dart/flutter

I want to check weather a String contains or not a specific substring in dart/flutter.
example
String mainString = "toyota allion 260 2010";
String substring = "allion";
I want to check weather substring is in the mainString or not?
Please help me to find a solution
String mainString = "toyota allion 260 2010";
String substring = "allion";
mainString.contains(substring); //return true if contains

Split String into 2 sub strings on first occurrence of comma?

I am trying to split String in to 2 sub_strings on the first appearance of comma character.
Also the first occurred comma must be removed.
Example :
Suppose this is the string
Manhattan Ave, Brooklyn,NY,USA
dividing this into this
Manhattan Ave
Brooklyn,NY,USA
also to note that first comma has been removed.
and finally saving these sub_string into variables.
String Place = "Manhattan Ave, Brooklyn,NY,USA";
String result_1 = Place.substring(0, Place.indexOf('.'));
String result_2 ="";
You can try this,
String place = "Manhattan Ave, Brooklyn,NY,USA";
int index = place.indexOf(',');
String result1 = place.substring(0,index).trim();
String result2 = place.substring(index+1).trim();

Verify and cut a string using regexp in matlab

I have the following string:
{'output',{'variable','VGRG_Pos_Var1/Parameters/D_foo'},'date',734704.60904050921}
I would like to verify the format of the string that the word 'variable' is the second word and i would like to retrive the string after the last '/' in the 3rd string (In this example 'D_foo').
how could i verify this and retrive the sting i search?
I tried the following:
regexp(str,'{''\w+'',{''variable'',''([(a-z)|(A-Z)|/|_])+')
without success
REMARK
The string to analysis is not splited after the komma, it is only due to length of the string.
EDIT
my string is:
'{''output'',{''variable'',''VGRG_Pos_Var1/Parameters/D_foo''},''date'',734704.60904050921}';
and not a cell, which could be understood. I added the sybol ' at the start and end of the string to symbolizied that it is a string.
I realise that you mention using regexp in the question, but I'm not sure if this is a requirement? If other solutions are acceptable you could try this:
str='{''output'',{''variable'',''VGRG_Pos_Var1/Parameters/D_foo''},''date'',734704.60904050921}';
parts1=textscan( str, '%s','delimiter',{',','{','}'},'MultipleDelimsAsOne',1);
parts2=textscan( parts1{1}{3}, '%s','delimiter',{'/',''''},'MultipleDelimsAsOne',1);
string=parts2{1}{end}
match=strcmp(parts1{1}{2},'variable')
To answer the first part of your question, you can write this:
str = {'output',{'variable','VGRG_Pos_Var1/Parameters/D_foo'},'date',734704.60904050921};
temp = str(2); %this holds the cell containing the two strings
if cmpstr(temp{1}(1), 'variable')
%do stuff
end
For the second part you can do this:
str = {'output',{'variable','VGRG_Pos_Var1/Parameters/D_foo'},'date',734704.60904050921};
temp = str(2); %like before, this contains the cell
temp = temp{1}(2); %this picks out the second string in the cell
temp = char(temp); %turns the item from a cell to a string
res = strsplit(temp, '/'); %splits the string where '/' are found, res is an array of strings
string = res(3); %assuming there will always be just 2 '/'s.

Regex Error in currency

I have a big problem, I used this codes to generate the number to currency,
Dim reg = New Regex("\d+")
Dim str As String = dZ.Rows(y).Item(14).ToString().Replace(",", ""). _
Replace(".00", "").Replace("$", "").Trim
Dim match = reg.Match(str)
If match.Success Then
str = reg.Replace(str, Decimal.Parse(match.Value).ToString("C"))
End If
yes it works, but what if my amount is:
1,900.50 POC
kelvzy your solution is not very flexible. I will suggest my solution:
string cellValue = dZ.Rows[y][14];
string cleanedCellValue = Regex.Replace(s, #"\s[^\d.,]+", "");
//this will replace everything after the last digit
string decimalValue = Convert.ToDecimal(cleanedCellValue, CultureInfo.InvariantCulture);
string str = decimalValue.ToString("C");
This solution will work, when each cell uses comma as thousand separator, dot as decimal separator and any symbols as currency symbol.
In other case give me please more examples

String operator += sometimes not working after string::resize()

Assuming:
std::string ToShow,NumStr;
The following displays "This is 19 ch00":
ToShow = "This is nineteen ch";
ToShow.resize(ToShow.length()+0);
NumStr = "00";
ToShow += NumStr;
mvaddstr(15,0,ToShow.c_str());
And the following displays "This is 19 ch ":
ToShow = "This is nineteen ch";
ToShow.resize(ToShow.length()+1);
NumStr = "0";
ToShow += NumStr;
mvaddstr(16,0,ToShow.c_str());
In the second case, operator+= isn't adding the string "0" to the end of ToShow. Does anyone know why?
My guess is:
You don't specify the value to resize with, so after ToShow.Resize(ToShow.length()+1) your string looks like:
"This is nineteen ch\0"
And after += NumStr:
"This is nineteen ch\00"
which, after calling c_str, gets trimmed to the first \0 and looks like:
"This is nineteen ch"
(C strings are null-terminated, std::strings aren't)
Try calling .resize(someLength, ' ') instead.