I am scraping a customer name as part of a data table from a website for a bot that I am building and then use string manipulation to get the first and last name. This worked at first, but the bot fails if there is a middle name. For example:
The website field is called ‘name’ and will state the customer’s name as ‘Joe Blogs’ and so I used this code:
pDictionary(“Name:”).Trim.Split(" “c)(0) - First name
pDictionary(“Name:”).Trim.Split(” "c)(1) - Second name
I then use and assign activity to turn the above code into a variable of FirstName or SecondName.
The issue is, if the customer name is ‘Joe S Blogs’ or ‘Joe Steven Blogs’ then the second name of course lists the second name as ‘S/Steven’ rather than ‘Blogs’.
How would I make it so that the bot can tell if there is a middle name and has to exclude it? Customer details of course change on a case-by-case basis.
Thank you, I think this will work, though I am now running in to a new problem and so cannot check haha.
I’m having an issue with the ‘company name’ field on the website; some customers have a company, but if they don’t then the field doesn’t appear. Therefore, when it scrapes the data table, my assign ‘pCompanyName = pDictionary(“Company Name:”)’ throws out an error.
I put this in a trycatch in hopes it would skip it, but the error keeps arising. Any ideas?