I have a table with spellings of words. Words are marked up in a such way:
h[e,a]llo
Where the first letter is the correct spelling, and the second is the wrong one. I need to make a selection in such a way that, for example, when "hallo" or "hello" is given, the desired word is found and passed in its original markup. Any ideas?
Related
I have a sheet with cells that contain formulas like this:
=IF(LEN('API Tool'!P358),IF('API Tool'!P358/POWER(10,18)>=C3+(C3*25/100),"API ERROR",'API
Tool'!P358/POWER(10,18)),)
And I would like to mass replace them all and add Indirect function to C cell references like this (check the bold letters):
=IF(LEN('API Tool'!P358),IF('API Tool'!P358/POWER(10,18)>=INDIRECT("$C3")+(INDIRECT("$C3") *25/100),"API
ERROR",'API Tool'!P159/POWER(10,18)),)
Is there any script or regular expression that i could use in order to mass replace all?
Thanks
First, using a "$" symbol with INDIRECT is redundant and, in this case, is also just complicating matters. Every part of every INDIRECT reference enclosed between quotation marks is a locked reference by nature.
That said, if the changes you want to make are in a specific range only, select that range first. If they are in an entire sheet or across the entire spreadsheet, move to the next step.
Hit Ctrl-H (or Cmd-H or Edit > Find and replace) to bring up the "Find and Replace" dialog box.
In the "Find" field, enter this:
([^A-Z])(C\d+)
In the "Replace with" field, enter this:
$1INDIRECT("$2")
Make sure that you set the "Search" location to match your desired scope. (If you selected a specific range and then choose "Specific range" here, the range you currently have selected will populate.)
Check the checkboxes for "Search using regular expressions" and "Also search within formulas." This will automatically also select "Match case" (since regular expressions are case-sensitive).
Click the "Replace all" button.
The REGEX has to include (and avoid) cases where a column may incidentally include C, such as a reference to Column AC, which is why it has two parts: one that makes sure the character preceding the C is not another valid column letter and one that grabs the direct part in question.
In addition, while this is not part of what you asked, I caution you to think through why you are replacing those direct references with INDIRECT ones. It's hard to imagine a case where that would be necessary. And once you change them to INDIRECT, if you add or delete columns or rows anywhere, those references will not adjust relative to those changes — which means every one of those references will then point to the wrong place thereafter.
I have a column in my access database table, I ran a query to make it proper case by using StrConv([MyColumn],3) but last two letters are state names and this query makes SOmeThing, soMethINg, NY to Something, Something, Ny,
I want the result as Something, Something, NY
Is there a another query I can run after to capitalize last letter?
You can use:
UcaseLast: Left([YourColumn], Len([YourColumn]) - 1) & UCase(Right([YourColumn], 1))
Well, most people would tell you to store your 'address', 'city', and 'state' as separate fields. Then you Proper Case each separately and concatenate them together. If you can do that... that is your best approach.
If this is a database or file that's been tossed at you and you can't make the field/table changes... it's still possible to get your desired results. However, you better make sure all strings end with your state code. Also make sure you don't have foreign addresses since Canadian (and other countries) use more that two letters for the province code at the end.
But if you are sure all records contain two letter state abbreviations, you can continue with the following:
MyColumnAdj: StrConv(Mid([MyColumn],1,len([MyColumn])-2),3) + StrConv(right([MyColumn],2),1)
This takes the midstring of your [MyColumn] from position 1 to the length of your [MyColumn] minus 2 (leaving off the state code) and it Proper Case's it all.
It then concatenates (using the plus sign) to a rightstring of [MyColumn] for a length of 2 and Upper Case's it.
Once again, this is dangerous if the field doesn't have the State Code consistently at the end of the string.
Best of luck. Hope this helps. :)
I have the following data in TableA...
ID | Text
---------------------------------------------
1 | let's find this document
2 | docments are closed
...and if I do the following select...
select Text from TableA where Text like '%doc%';
...I seem to get a strange result. Both rows are returned. With this select, should it not only return row 1? I would have thought that..
select Text from TableA where Text like 'doc%';
...would have returned just row 2. Am I missing something?
What I'm trying to do is run 3 separate searches across this data as part of my searching tool. The first match is to look for the specified pattern "doc" at the beginning of a string, secondly, my next match looks for the same pattern but at the end of a string, and thirdly, identify if the pattern appears anywhere within the text - so can have text surrounding it. Ideally, the first search would only match row 2, the second search would return no results and the third result would only return row 1.The reason for doing it like this is I wanted to try and get a feel for how the pattern matched the string. Would make it easier to read the results to know that the pattern for a given row matched either (a) at the beginning, (b) at the end, (c) anywhere in the middle.Had thought about using regexp, but my data is unicode.
No, the first query returns both rows, because % means 0 or more characters. So if doc is the first thing appearing in the field, it matches the %doc% pattern as well.
But you're right on the second query, it will only return row 2.
doc_% should match it at the beginning, having at least one character after it.
%_doc should match it at the end, having at least one character before it.
%_doc_% should match it anywhere, having at least one character before and after it.
Note that these strict criteria fail to find the exact string "doc", i.e. with nothing before or after it. You may want to include this case in, say, query #1, by loosening it:
doc% should match it at the beginning, having any number of characters after it.
I probably am missing something very simple here, but I cannot see it. MSAccess is sorting strangely, to test this I have created a simple one text field table and inserted these values:
BB0-01
BB001-0
BB0-01a
Now, according to little old me, since BB0-01 and BB0-01a have the first 6 characters in common, and BB001-0 already deviates at the 4th, the -01 and -01a should be sorted close to each other, something like:
BB0-01
BB0-01a
BB001-0
But they are not. The sorted order is as in the first list, with the -0 in between the -01 and -01a. Reverse sorting puts the -01a at position #1 but the -0 stays in between them. How can this be?
Looks like the sorting disregards -
Can't find anything in the MS Access doc that says anything about it though.
People have different ideas of how to search for the same term.
For example Tri-Valley, Trivalley, Tri Valley (and possibly even incorrect spellings)
Currently that search is done like this
SELECT * FROM `table` WHERE `SchoolDistrict` LIKE '%tri valley%';
Is there an easy way to say 'space dash or no space' without writing out three like statements?
It seems like it could easily be done:
SELECT * FROM `table` WHERE `SchoolDistrict` LIKE '%tri%valley%';
But this only works if the initial input is 'tri-valley' or 'tri valley' If the initial input is 'trivalley' I have no idea where to place the % (theoretically that is, actually, I do, as we are only looking at about a dozen different school districts, but I'm looking to solve the larger problem)
You could consider using SOUNDEX, or SOUNDS LIKE if you have a lot of incorrect spellings. If you've got a lot of rows (or even if you don't), it might be wise to store the output of the SOUNDEX in an additional column.
I'd also recommend -- in the interests of accuracy -- introducing a separate table with an authoritative list of school districts, and run a query to find those which aren't in that list.
MySQL has a function called Sounds like.
link text
An alternative here is to recast the problem from search to select, if possible. Instead of letting your users enter free-form text to choose a school district, if you have a set of school districts generate a dropdown (or set of cascading dropdowns if the list is large, say by county, then by school district) and allow the user to select the appropriate one. Use this both for "searching" and for data entry to eliminate non-canonical entries. Obviously this only works when you can enumerate all of the entries.
Alternatively you could allow the user to choose a starts with or contains type search and simply generate the appropriate SQL ('tri%' or '%tri%') based on the selected search type. If the user understands that the search type is starts with or contains, they will likely adjust their search string until it yields the results they need.
The second statement you posted should do the trick:
SELECT * FROM 'table' WHERE 'SchoolDistrict' LIKE '%tri%valley%';
What you should do before you pass the search term into the select statement is to replace all characters and spaces with the % sign. For example,
SearchTerm = SearchTerm.Replace(" ","%");