Splitting a full name field into first and last name - string

I have a form with a full-name text field and I would like to break the string into a first and last name strings... I'm handling the form in Coldufusion.
What is the most reliable way to achieve this? I'm assuming JavaScript is not an option since, in its absence, the form would generate an error. Any examples would be great.
Thanks

Found a better solution
<cfset fullName = "foo bar">
<cfset firstName = listFirst(fullName, " ")>
<cfset lastName = listRest(fullName, " ")>

If you just want to split on the first space, you can use the list functions. For example, you could get the first word by using
<cfset first = listfirst(fullname, " ")>
List functions all take an optional parameter, delimiters, which lets you specify how the list is delimited. So, in this case, your list is space-delimited.
Remember that not all names are two words. People use middle names, constructs like "De Marco" and "Van DeGraff" and so forth, or multiple first names like "Lisa Ann". But this will get you a good approximation.

In coldfusion, after it is submitted, I would split it on a space character.

You can use GetToken(fullname,1) and getToken(fullName,2)

Related

Using the replace function in Netsuite for components in assemblies

Very new to Netsuite. I'm trying to use a saved item search to find all instances of {componentitem} entry is 800484 and replace them with component 516551302688
I'm using the REPLACE function in the saved item search but it doesn't like my formula REPLACE(800484, [, 516551302688]){componentitem}
I'm sure I am doing something wrong in the formula but unsure what it is.
The function signature for REPLACE is:
REPLACE(char, search_string, replacement_string)
char is the text to search in.
search_string is the text to search for.
replacement_string is the text to replace the search_string with, where found.
What you have appears to be more like
REPLACE(search_string, replacement_string)char
The text you want to search in is outside of the function altogether (outside the parentheses that enclose what the function will act on). You also have additional brackets and a comma in your formula.
Based you the information in your question, your formula should be
REPLACE({componentitem}, '800484', '516551302688')
I have wrapped the search and replacement strings in quotes as REPLACE deals with strings. If you leave the quotes off, the database will infer the string values of the numbers given and it will still work, but it's best practice to be explicit.
Note that this will only replace the values within the results of the saved search, and will have no effect on the underlying records. Hopefully you already know this, but I just mention it as the wording of your question makes it appear as if you're expecting it to substitute the actual components.
HTH.

How to find and remove multiple words (as a list) from a cell without using macro

I have a string in a cell which is a list of words like this:
a,b,c,d,e,f,g,h,f,c,a,h
I'd like to find and remove all the words which are on this list:
c,f,h
I can use multiple SUBSTITUTE but since my list is long, nested SUBSTITUTE is not convenient.
Here is the example sheet: https://docs.google.com/spreadsheets/d/11ZT3CMJ9vfUcOIvhXYLHUHHQm5tm1Tb1N9hi3LeI0WM/edit#gid=0
There is also a solution here but I'd like to use an existing list instead of manually inserting to the function.
You can use an existing list instead of manually inserting to the function.
Make a list of the words you want replaced in a column eg. A3:A9 and use the following formula to create your expression.
=JOIN("|",A3:A9)
Then use the working solution from your mentioned answer (or whichever formula meets your needs) to get the final result.
=REGEXREPLACE(A1,"\b("&B3&")\b",)
This is a second version based on suggestions from #marikamitsos
, I have added a string ", .. $" to the last partern position because there is no comma at the end of the text in a1.
=RegexReplace(RegexReplace(A1&",","\b(" & SUBSTITUTE(A3&",",",",",|") & ")(\b|$)",""),",$","")
In addition to previous answer, you can also try
=textjoin(",", 1, ArrayFormula(regexreplace(split(A2, ","), textjoin("|",1,A5:A8),)))

Looking to remove a space in one of the results while performing multiple mid searches on a column

I am trying to embed a SUBSTITUTE in my function, but I am not sure where to incorporate it. I am trying to extract just the text "Scrumactiviteiten" but in the source data sometimes a space will be in there. A sample:
Column A
1 Team xxxx 2018-17 Scrumactiviteiten 123 and then something
2 Team xxxx 2018-17 Scrum activiteiten 123 and then something
Column B (My formula)
1 Scrumactiviteiten
2 Scrum activiteiten
The function I used to extract it (ignore the "Balans" search please):
=IFERROR(IFERROR(IFERROR(MID(A1;SEARCH("Scrum activiteiten";A1;1);18);
MID(A1;SEARCH("Scrumactiviteiten";A1;1);17));MID(A1;SEARCH("Balans";A1;1);10));" ")
This works fine, but to remove the space I tried to embed a SUBSTITUTE where I use the mid search result as the old text and provide "Scrumactiviteiten" as the new text:
=IFERROR(IFERROR(IFERROR(SUBSTITUTE(A24;((MID(A24;SEARCH("Scrum activiteiten";A24;1);18)));"Scrumactiviteiten");MID(A24;SEARCH("Scrumactiviteiten";A24;1);17));MID(A24;SEARCH("Balans";A24;1);10));" ")
The result however is a copy of the full string. I also tried putting the substitute before the search but that would not work either. I am pretty new to Excel formula's and I think I messed up the order or just plain don't understand how I embed a SUBSTITUTE in the formula I created. Some explanation would be much appreciated on what I'm doing wrong! Thank you in advance,
Mark
The problem is you are not providing the correct arguments to the function, try this formula:
=IFERROR(IFERROR(IFERROR(SUBSTITUTE(((MID(A24;SEARCH("Scrum activiteiten";A24;1);18)));" ";"");MID(A24;SEARCH("Scrumactiviteiten";A24;1);17));MID(A24;SEARCH("Balans";A24;1);10));" ")
To use SUBSTITUTE you first provide the string in which you want to replace something, the next two arguments are the string you want replaced and the string you want to replace it with. So for example =SUBSTITUTE("Scrum activiteiten";" ";"") returns Scrumactiviteiten as the space " " is replaced with an empty string "".

How to eval a field name contained in another field in an Access Query?

I need to create a long list of complex strings, containing the data of different fields in different places to create explanatory reports.
The only way I conceived, in Access 2010, is to save text parts in a table, together with field names to be used to compose the string to be shown (see line1 expression in figure). Briefly:
//field A contain a string with a field name:
A = "[Quantity]"
//query expression:
=EVAL(A)
//return error instead the number contained in field [Quantity], present in the query dataset
I thought doing an EVAL on a field (A), to obtain the value of the field (B) which name is contained in field A. But seems not working.
Any way exist?
Example (very simplified):
Sample query that EVAL a field containing other field names to obtain the value of the fields
Any Idea?
PS: Sorry for my english, not my mothertongue.
I found a interesting workaround in another forum.
Other people had same problem using EVAL, but found that it is possible to substitute a string with a field contents using REPLACE function.
REPLACE("The value of field Quantity is {Quantity}";"{Quantity}";[Quantity])
( {} are used only for clarity, not needed if one knows that words to be substituted do not compare in the string). Using this code in a query, and nesting as many REPLACE as many different fields one want to use:
REPLACE(REPLACE("<Salutation> <Name>";"<Salutation>";[Salutation]);"<Name>";[Name])
it is possible to embed fields name in a string and substitute them with the current value of that field in a query. Of course the latter example can be done more simply with a concatenation (&), but if the string is contained in a field instead that hardcoded, it can be linked to records as needed.
REPLACE(REPLACE([DescriptiveString];"[Salutation]";[Salutation]);"[Name]";[Name])
Moreover, it is possibile to create complex strings context-based as:
REPLACE(REPLACE(REPLACE("{Salutation} {Name} {MaidenName}";"{Salutation}";[Salutation]);"{Name}";[Name]);"{MaidenName}";IIF(Isnull([MaidenName]);"";[MaidenName]))
The hard part is to enumerate all the field's placeholders one wants to insert in the string (like {Quantity},{Salutation}, {Name}, {MaidenName}) in the REPLACE call, while with EVAL one would avoid this boring part, if only it was working.
Not as neat as I would, but works.

Replacing Delimiter in MCONCAT formula

I'm using the MCONCAT formula (with success & help from others) to create a single string of multiple attachment names to associate them with a single record # (I am converting data from a legacy system to another by way of flat files and a data loader).
An example: | Contract 1 | filename.pdf, filename2.doc |
However, when the first load was run, records that had a comma in the name error-ed out because the data loader is viewing the comma as the break between files. After some research, we decided to use '#' as the delimiter between multiple files in a cell. Now I am stuck trying to substitute the comma delimiters in my MCONCAT formula with '#' and have been fruitless so far.
Here is the code as I am using it now:
=SUBSTITUTE(MCONCAT(IF($A$2:$A$11133=$D2,", "&$B$2:$B$11133,"")),", ","",1)
Is this possible to do? If so, how & maybe (if not asking to much) a short explanation so I can fully understand.
An example of the hopeful solution: | Contract 1 | filename.pdf # filename2.doc |
Depending on the complexity of the filenames with commas in, you might be able to do what you want simply using the Find & Select / Replace feature of excel.
Please use a copy of your workbook if you try anything suggested.
If your separator is always [list item][comma][space][list item] and none of your [list item(s)] contain [comma][space] then using a "find what" term of ", " (note the space!) and "replace with" term of "# ", Using [at][space] instead of [space][at][space] is probably better, and selecting the column containing the list should fix your problem.
A VBA solution is possible but it would probably be more effort than its worth. You might need to write lots of rules telling it how to split and join stuff, and end up with it still not being perfect.
While doing it manually might not be a fun idea, you could use something like "text to columns" to split your list then look over the results and fix the errors then re-join using your new delimiter.

Resources