community
I am looking to compare partial strings of data thats in two seperate columns. And if its a match print a statement in a third column like " yes its a match" or "there is no match". The problem is there is extra data in the first column so it wont be an exact match so I'm essentially searching or comparing certian words. I have over 8000 rows and doing it one by one would take forever is there a function I can use in excel to make this process easier.
In Excel you can combine SEARCH() and ISERROR().
SEARCH() returns the index of the start of a string match, or the #VALUE error otherwise. Using IF(ISERROR()) on this will let you output something based on whether there was a match or not.
=IF(ISERROR(SEARCH(B2,A2)),"No Match", "Match")
Related
I am new to Java and I am trying to write a program for finding a specific string value in CSV documents that use a pipe ( | ) as the delimiter (only using core Java, so no CSVreader library). I need to find a specific string "Employee Name" in the CSV docs, but since they are inconsistently formatted, I want the program to essentially use the searched string("Employee Name") as the column header and return all of the values under it, until it reaches the null value at the end of the list (the number of elements that would be in said column are unknown).
I was planning on using the Scanner class with a series of loops to keep track of the number of Delimiter occurrences per line (that is, restarting the count after every linebreak) so that I could use the relative location of the searched string to retrieve the values under it that would be a part of it as a "column". (So if there were 3 Delimiters before "Employee Name" was matched on line 4, the program would return the values of the field that is 3 Delimiters in for Line 5, Line 6, Line 7, etc until it hits a null value in one of the lines.
Sidenote: I am trying to allow for the search term to permit Whitespaces (such as in the case of "Employee Name", so I have been using the custom Delimiter:
scanner.UseDelimiter("[|\r\n]")
If this regex isn't correct for the task I am trying to accomplish, please let me know.
I would sincerely appreciate any suggestions or guidance in solving this.
I must extract a sub-string but only if a condition is met.
The users in this column must fill the telephone numbers of clients (It's a varchar column),
Some examples of those stored values are:
23==880-3112==9435
52==031 31466==171
321==15850
The '=' are numbers I don't wanna share.
I need to extract the mobile number (The one with the length of 10), but as you can see, those numbers are not stored in the same positions, I can't use a LEFT() or RIGHT() function because of that, some are separated with '-', others with spaces between the house number and mobile number.
If this can't be done with SQL, I'm using Java but I don't even know where to start.
Thanks in advance.
EDIT:
I'm using SQL SERVER 2012
The expected results from the examples are
3112==9435
31466==171
312==15850
I want to obtain always the 10 characters number.
Sorry and thanks
You can use String comparison function
Where part of your 1st example will be
WHERE TELEPHONE_NO LIKE '23%%880-3112%%9435'
[Edit]
To extract a substring you can use https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring-index
mysql> SELECT SUBSTRING_INDEX('23==880-3112==9435', '-', 10);
-> '3112==9435'
I am studying for an interview and having trouble with this question.
Basically, you have a word that has spaces in it like c_t.
You have a word bank and have to find all the possible words that can be made with the given string. So for in this case, if cat was in the word bank we would return true.
Any help on solving this question (like an optimal algorithm would be appreciated).
I think we can start with checking lengths of strings in the word bank and then maybe use a hashmap somehow.
Step 1.) Eliminate all words in the wordbook that don't have the same length as the specified one.
Step 2.) Eliminate all words in the bank that don't have the same starting sequence and ending sequence.
Step 3.) If the specified string is fragmented like c_ter_il_ar, for each word left in the bank check if it contains the isolated sequences at those exact same indexes such as ter and il and eliminate those that don't have it
Step 4.) At this point all the words left in the bank are viable solutions, so return true if the bank is non-empty
It may depend on what your interviewer is looking for... creativity, knowledge of algorithms, mastery of data structures? One off-the-cuff solution would be to substitute underscores for any spaces and use a LIKE clause in a SQL query.
SELECT word FROM dictionary WHERE word LIKE 'c_t'; should return "cat", "cot" and "cut".
If you're being evaluated on your ability to divide and conquer, then you should be able to reason whether it's more work to extract a list of candidate words and evaluate each against your criteria, or to generate a list of candidate words from your criteria and evaluate each against your dictionary.
I have two tables' contents stored in Stringbuffers. One has data in it; the other is only a header. I converted the Stringbuffers into Strings and removed whitespace.
table1:
ACCOUNT_NUMBER;BRANCH_CODE;RECALC_ACTION_CODE;RECALC_DATE;PROCESS_NO;PRINCIPAL_CHG_AMXX23QRUP120970003;023;E;05.09.2013;1;-522.53
table2:
ACCOUNT_NUMBER;BRANCH_CODE;MSG_TYPE
I only want to proceed with a table if it has data in it, like table1.
To check for data (i.e integers) I used regex: table1.matches("\\d"), but this returns false. I also tried table1.matches("(?s)\\d")), for new line character but even this returns false.
How can I check for integer data in the strings?
Read the documentation on matches. The "match" requires the entire string to match, and so your table1.matches("\\d") fails -- "table1" is not 'one digit only'.
Use table1.matches(".*\\d.*") instead. Note the double backslash! You might not be aware they need escaping in a String constant.
I have 100 words. All 100 words are look like this.
EnglishWord,EngMeaning,NumberofW… meaning,31
In that I want to retrieve EnglishWord, e.g. Friendship alone for 100 words by using Java program.
I am assuming you have a "body" (main string), containing a list of substrings and you want to retrieve any specific one substring from within.
This looks a lot like homework/exercise, so I'll avoid giving you a ready-to-roll answer, since you need to achieve a solution yourself for it to be of any value, but the general steps you will need are the following:
1:
Be able to separate each substring (entry) from the others (the base string) in an organized fashion.
This can be done (for the string case), as #kylc said, with String's split function, which uses a REGEX (PATTERN) to define divisors (one or more), that then is/are used to divide the string into an array of multiple substrings.
String[] arrayOfEntries /*something to hold the result*/ = yourStringVar.split("," /*your split regex pattern*/);
NOTE: For more information on these, here are the links: String's split function, Pattern.
2:
Be able to acquire any specific entry withing an array of entries.
This is best done with a function you can reuse for other works. You need to define a "target" (what/which is going to be acquired) and a "source" (group of entries to acquire "target" from).
All you have to do is loop the "source", and for each entry there, compare to "target" for a match; When a match is found, just return it.
That's it! The rest is up to you!