Getting the word the appeears after a specific word in flutter - flutter

I have this string.
String message = 'QG935XSVSD Confirmed. Your account balance was: M-PESA Account : Ksh0.00 on 9/7/22 at 12:33 PM. Transaction cost, Ksh0.00. Dial *334# now to get your stamped M-Pesa Statement.'
I want to get the word that appears right after cost, in this case Ksh0.00 . I would try and pick the word by its position but the message might get additional words affecting its length.

If you are sure about the string structure, simplest solution would probably be .split() method.
final cost = message.split('cost, ')[1].split(' ')[0];

Related

how to solve actions on google-Api.ai error

Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.
Short answer - check here for screenshots http://imgur.com/a/tVBlD
Long answer - You have two options
1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter
2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.
If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.
Note the second route is what I did to solve a similar issue.
You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.
Python regex search example
baseurl = "http://mywebsite.com:9001/"
# Parse the document
# Build the URL + File Path and Parse the Document
url = baseurl + 'Data'
xmlLink = urllib.request.urlopen(url)
xmlData = etree.parse(xmlLink)
xmlLink.close()
# Find the number of elements to cycle through
numberOfElements = xmlData.xpath("count(//myData/data)")
numberOfElements = int(numberOfElements)
types = xmlData.xpath("//myData/data")
# Search the string
i = 0
while numberOfElements > i:
listSearch= types[i].text
match = re.search(parameter, listSearch, re.IGNORECASE)
if match is None:
i += 1
else:
# Grab the ID
elementID = types[i].get('id')
i = 0
break
An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.

How to Remove zero amount line fom axapta form by code

When we are processing EOS(end of service) of an employee then system automatically generate the zero line 0.00 as Encashment quantity for rendom employee somehow.My client don't want this zero line in this form becuase when they are trying to post EOS to general ledger its showing the error as amount can't be post without value.So how to code in x++ to remove the zero amount line from my EOS form if there is any 0.00 encashment amount.
enter image description here
In Above screenshot system has calculated the encashment quantity as zero so when we processed EOS. Kindly requesting give some suggestions to handle this scenario by X++ code.
If you are using a datasource to get the value then there is a property called "Insert if empty" on the datasource (In this case the datasource with the EncashmentQuantity field) which is automatically set as "yes" but you can change it to "no" and the value should not be shown if it is 0. I am not sure this is what you are talking about but it might be.
I hope to understood the question.
"My client don't want this zero line in this form becuase...."
I think you have this way, If you want to filter the record without 0 Value by code, you can use filter in DataSource rightClick override executequery method and insert code looklike follow:
public void executeQuery()
{
this.query().dataSourceTable(tableNum(**YourTablename**)).addRange(fieldNum(**YourTableName**,**YoutFilterField**)).value(strFmt("%1", '>0'));
super();
}
ForExample :
this.query().dataSourceTable(tableNum(LedgerJournalTrans)).addRange(fieldNum(LedgerJournalTrans,AmountCurCredit)).value(strFmt("%1", '>0')); // DISCARD all record lower than 0
or
this.query().dataSourceTable(tableNum(LedgerJournalTrans)).addRange(fieldNum(LedgerJournalTrans,AmountCurCredit)).value(SysQuery::valueNot(0));
I share this useful links :
Expressions in query ranges
SimilarQuestion
StandardGuide
Good work!

TSQL Find and Replace in String

I have a table that I use for error logging when inserts fail on the front end of my site. It stores the params URL as a text string so we can see what values were sent over and why it may have failed.
Well I am now working with this data to try and recover some records from it.
This is what the record looks like in my field:
xml=<data><optional><Account>192070041</Account></optional></data>, submitter=Q1370, target=Q1234, escalationType=esc, escalationReason=277, feedback=cx req live esc to have us release his alh payment for 8487.18, adv cx his funds are eligble for release on july 2nd at 445 pm est, preventable=0,
The issue I am running into recovering some data is that on a script I am writing in PHP, I am getting all of the params individualy by exploding on the = sign to get each of the values.
Well, the feedback= section happens to be comments that contains commas and its messing up a lot of stuff.
What I need to do is within the string, I need to find everything in feedback=xxxxxxxxxx, and either remove all the commas from that section or replace with with a | pipe so I can just change them back later.
My lack of knowledge in this area is where I hope some one can point me in the right direction so I can get some records restored on a mass level.
Example:
Before String - param1=dfsfsf, param2=fdsfsdfds, param3=bob, how are you doing today?
After String - param1=dfsfsf, param2=fdsfsdfds, param3=bob| how are you doing today?
UPDATE YourTable SET URL=REPLACE(URL,',','|')
See https://msdn.microsoft.com/en-us/library/ms186862.aspx and https://msdn.microsoft.com/en-us/library/ms181984.aspx
Later edit: I read your question more carefully and I now understand that you want to replace only the commas in after a certain substring. Try something like this:
DECLARE #URL NVARCHAR(1000)
SET #URL='Before String - param1=dfsfsf, param2=fdsfsdfds, param3=bob, how are you doing today?'
SELECT LEFT(#URL,ISNULL(NULLIF(CHARINDEX('param3=',#URL),0),LEN(#URL)))
+ISNULL(REPLACE(SUBSTRING(#URL,NULLIF(CHARINDEX('param3=',#URL),0),1000),',','|'),'')

How to send email to multiple addresses in range of cells that updates weekly?

I am a novice at programming. I have setup a google spreadsheet that will send a weekly email reminder to those who have upcoming assignments. The spreadsheet automatically pulls the 4 email addresses of those who are assigned each week and places them in A1, B1, A2, B2 (i.e. A1:B2). I want the script to find the 4 email addresses (that change each week) and send the same email to all four of them.
When I hardcode the cc recipients into the MailApp line, it works fine. But because the recipients list changes weekly I want to reference the cells A1:B2 instead. When I try to do that, I get an Invalid Email error. The debugger shows that var ccrecipients is picking up the right cells, but I think the problem is that it returns it as an array instead of as a string. That's as far as I'm able to reason through it.
A few snippets of my code:
var ccrecipients = sheet.getRange('A1:B2').getValues();
MailApp.sendEmail(recipients, subject, "", {htmlBody: message, cc: ccrecipients});
Thanks in advance for your help. I've relied heavily on these forums to put together the code that I have. I've always been able to find an answer, until this one. Thanks!
Your observation is almost correct, sheet.getRange('A1:B2').getValues(); return an array of arrays, something like [[A1,B1],[A2,B2]] A & B representing the values in the cells to simplify my example.
And what you need in the end is a "flat" string with all the needed recipients separated by commas "A1,B1,A2,B2".
The simplest way to do that is to flatten the whole thing,that will create a string with comma separations and that's exactly what we need.
sheet.getRange('A1:B2').getValues().toString();
That should do the trick ;-)

What is the meaning of the following line of code?

I am learning ADO.NET and now I am trying to understand the SqlDataReader. I am trying to learning by using this tutorial and I am facing some difficulties now in understanding the following part of the code mentioned HERE:
while (rdr.Read())
{
// get the results of each column
string contact = (string)rdr["ContactName"];
string company = (string)rdr["CompanyName"];
string city = (string)rdr["City"];
// print out the results
Console.Write("{0,-25}", contact);
Console.Write("{0,-20}", city);
Console.Write("{0,-25}", company);
Console.WriteLine();
}
I want to understand the meaning of "{0, -25}"
This means that the WriteLine method schould print the value of the first parameter, in your case contact, to a width of 25 characters. The minus in front of the 25 indicates a left justified output.
That is a format specifier for .NET Console.Write().
See documentation explaining here:
http://msdn.microsoft.com/en-us/library/9xdyw6yk.aspx
IN SqlDataReader, it reads record from database based on query.
sqlDataReader read record at a time single row. it means rdr["ContactName"] is one value and it read and move to string contact and so on every fields.
It fetch all record in while loop.
And Console.Write("{0,-25}", contact) is used to format output.