Search function to send all variations of the text uppercase an lowercase - search

I have a function that uses an api to pull information based on the text given in the request.
The problem is that the text has to match the item exactly. Such as the item is named "Peach and Apple" and if you type "peach and apple" it will not return. You have to type "Peach and Apple" in order to properly request the item.
Is there a way I can send every variation of "Peach and Apple" (just incase is was something weird like "Peach and Le'Apple") with every variation of an uppercase letter?
I could make it uppercase every letter at the start of the string which is easy and would work with a lot of requests. Then I could uppercase every letter after a space which with the previous change would handle ALMOST every search.
The problem is I cannot make it uppercase every letter after a ' for this example(reason):
"Peach and Le'Apple" would work but "Peach and Apple's Leaf" would not work since the s is not uppercase. Thus is there a way to properly search for this?
Thanks for your time!!!

So I figured a way around it. The problem was that the items I was searching for had to be in the exact form. I was the one that saved those items from the api. So when I save them now I have 2 separate columns. One that saves the name with uppercase that will be what is shown on screen and another that saves the same name only purely converted to lowercase with toLowerCase(). This lets me search for the items and still keep the nice uppercase name without having to do some nasty logic I dont want to do.

Related

How to make an excel (365) function that recognizes different words in the same cell and changes them individually

What im working with
I have a list of product names, but unfortunately they are written in uppercase I now want to make only the first letter uppercase and the rest lowercase but I also want all words with 3 or less symbols to stay uppercase
im trying if functions but nothing is really working
i use the german excel version but i would be happy if someone has any idea on how to do it im trying different functions for hours but nothing is working
=IF(LENGTH(C6)<=3,UPPER(C6),UPPER(LEFT(C6,1))&LOWER(RIGHT(C6,LENGTH(C6)-1)))
but its a #NAME error excel does not recognize the first and the last bracket
This is hard! Let me explain:
I do believe there are German words in the mix that are below 4 characters in length that you should exclude. My German isn't great but there would probably be a huge deal of words below 4 characters;
There seems to be substrings that are 3+ characters in length but should probably stay uppercase, e.g. '550E/ER';
There seem to be quite a bunch of characters that could be used as delimiters to split the input into 'words'. It's hard to catch any of them without a full list;
Possible other reasons;
With the above in mind I think it's safe to say that we can try to accomplish something that you want as best as we can. Therefor I'd suggest
To split on multiple characters;
Exclude certain words from being uppercase when length < 3;
Include certain words to be uppercase when length > 3 and digits are present;
Assume 1st character could be made uppercase in any input;
For example:
Formula in B1:
=MAP(A1:A5,LAMBDA(v,LET(x,TEXTSPLIT(v,{"-","/"," ","."},,1),y,TEXTSPLIT(v,x,,1),z,TEXTJOIN(y,,MAP(x,LAMBDA(w,IF(SUM(--(w={"zu","ein","für","aus"})),LOWER(w),IF((LEN(w)<4)+SUM(IFERROR(FIND(SEQUENCE(10,,0),w),)),UPPER(w),LOWER(w)))))),UPPER(LEFT(z))&MID(z,2,LEN(v)))))
You can see how difficult it is to capture each and every possibility;
The minute you exclude a few words, another will pop-up (the 'x' between numbers for example. Which should stay upper/lower-case depending on the context it is found in);
The second you include words containing digits, you notice that some should be excluded ('00SICHERUNGS....');
If the 1st character would be a digit, the whole above solution would not change 1st alpha-char in upper;
Maybe some characters shouldn't be used as delimiters based on context? Think about hypenated words;
Possible other reasons.
Point is, this is not just hard, it's extremely hard if not impossible to do on the type of data you are currently working with! Even if one is proficient with writing a regular expression (chuck in all (non-available to Excel) tokens, quantifiers and methods if you like), I'd doubt all edge-case could be covered.
Because you are dealing with any number of words in a cell you'll need to get crafty with this one. Thankfully there is TEXTSPLIT() and TEXTJOIN() that can make short work of splitting the text into words, where we can then test the length, change the capitalization, and then join them back together all in one formula:
=TEXTJOIN(" ", TRUE, IF(LEN(TEXTSPLIT(C6," "))<=3,UPPER(TEXTSPLIT(C6," ")),PROPER(TEXTSPLIT(C6," "))))
Also used PROPER() formula as well, which only capitalizes the first character of a word.

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.

Remove everything after hyphen in hyphenated names in Excel using Formula

I am in charge of adding new employees to our speech recognition and gamification systems.
When I get a batch of tickets, I compile a bunch of data into a spreadsheet that I then reference when adding those users to the systems (Which unfortunately do not have a JSON/CSV upload option or anything similar)
To save some time with compiling, I've started exporting a bunch of data from our database and our HR management system into that sheet, and then using the new employee's email to XLOOKUP all the other data fields.
For one of our systems, it has a strict character limit, and the format for the username is "cde\firstname.lastname". This is no problem to CONCATENATE normally, but it has a strict character limit, so if the user has a hyphenated last name, I will basically dump everything after the hyphen.
At first I tried a simple formula using a combination of LEFT and FIND -1 to find the hyphen, and then take everything to the left of it. This obviously doesn't end up working because I get a #VALUE! for anyone without a hyphen in their last name.
I tried using IFERROR to say "OK try to return the last name without a hyphen, otherwise just return the last name", but for some reason when I put the reference in the Return_If_Error portion, it doesn't recognize it as a reference.
So I am looking for a formula that will work with a LOOKUP'd value and only give me what's before a hyphen, but otherwise will still just give me the last name.
The baseline formula I have, that just looks up and concatenates the first and last into the "cde\firstname.lastname" is:
=CONCATENATE("cde\",LOWER(XLOOKUP(G578,Sheet4!M:M,Sheet4!B:B)),".",LOWER(XLOOKUP(G578,Sheet4!M:M,Sheet4!C:C)))
To expand on the comments, you've got the right idea, just use an IF statement for testing if the string contains "-", then use the normal string functions like FIND, LEFT, etc. to pick out the things you want.
For example:
="cde/"&
LEFT(H1,FIND(".",H1)-1)&
IF(ISNUMBER(FIND("-",H1)),MID(H1,FIND(".",H1),FIND("-",H1)-FIND(".",H1)),
MID(H1,FIND(".",H1),FIND("#",H1)-FIND(".",H1)))

How to insert letter between two letter in a text input?

I want to make a function in a module i have made, to insert letter’ s before some specific letter ''vowel in fac'' in a text input. The text can be everything written by everybody. Can be letter, number, symbol. But for this function it will be only for letter’s.
Fist fonction.
For exemple, in the input field : (John get in2 the train.)
I want when i press on the button of my function,
that the result show : (javohn gavet avin2 thave travain)
Second function.
And make the same in the reverses procedure ,
input field :(javohn gavet avin2 thave travain)
and the after i press the button : John get in2 the train.
I have made something whit a dictionnaire in another programme and change all the letter’s in a text by another one and do the reverse, and work well. But this don’t work for what i want do to whit insertion of letter in a text. Or i miss something….I’m new in programming, but i love this, and a lot to learn. Im a self learning….. Thank for your help or ‘’Q’’ in the good direction.
I put a picture of my code.
[the code1
this one work well for another application, but not here for what i want to do.
I recommend regex for this. Specifically the sub() function. If you wanted to replace every 'e' and 'i' with 've' and 'vi', you could do this:
re.sub(r"[ei]",lambda x:"v"+x.group(0),my_text)
where my_text is a variable containing the text input.
For your second function, it would be something like:
re.sub(r"ve|vi",lambda x:x.group(0)[1],my_text)
The way this sub() function works is that it finds every match of the regex pattern, then applies a function to get the replacement string. In the first case it adds a 'v' in front. In the second case it takes the second letter.

VB Split Multiple Spaces and Remove Words

I'm making a little program so I can get a better view of donations for a game.
What I want the program to do is split the text from textbox1.text into multiple textboxes.
Example: I want to split this text "20:12 01-04-2014 Ramon Geen $4.500.000.000".
So I want the name "Ramon" in a textbox called Name1 and I want the money in a textbox called Donation.
I already know how to remove the date from the text but I don't know how to remove the comment which can be different than Geen and I also don't know how to split the name and donation into separate textboxes. Can anyone tell me how to go about doing this?
Thanks in advance!
If the string is going to be completely variable then you may have some issues.
However, you know the following.
The right most text is always the money, so you can split the string on space and then put it into an array. Then the last element in the array will be the money. Also, the first portion will be the date. The second item in the array will be the name and everything else will be the comment.
I'm not going to code it all out for you, but if you have any questions just post the code and ill take a look.

Resources