Replacing Part of a String in Access Query - Wildcard Characters - regex

I have an old hyperlink field that was never linked to the correct path. The field still has relevance though in that it contains the filename associated with the record. I'm trying to update this field by removing the path and leaving just the filename. Hyperlink functionality is not needed.
I've already converted the field to text and removed the hashes so all that remains is the incomplete filepath string. The paths are all similar in format but vary in foldername\filename.
"FOLDERNAME\FILENAME.tif"
In example: "RESEARCH LAB 22\RESEARCH LAB 22 001.tif"
I have the following query, but it requires replacing the foldername manually.
UPDATE BAT1_Document SET BAT1_Document.HYPERLINK = Replace([Hyperlink],"RESEARCH LAB 22\","");
Replacing "*\" with "" would cover my needs but my understanding is that wildcard characters can't be used in a Replace update query so I am at a loss as to how to implement this.

If there are allways "FOLDERNAME\FILENAME.tif" then try:
UPDATE BAT1_Document SET BAT1_Document.HYPERLINK = mid([Hyperlink],instr(1,[Hyperlink],"\")+1);

Related

How to extract and route only specified columns from a CSV files and drop all other columns [duplicate]

This question already has an answer here:
How to extract a subset from a CSV file using NiFi
(1 answer)
Closed 4 years ago.
I want to extract few fields along with its value from a CSV file and drop/delete all other fields in the file. Please help. I think we can use RoutText processor.Please tell me how to write the regular expression for the routing only specified fields and dropping everything else. Thanks
Example- from he snapshot attached I only want to route 'Firstname,Lastname and Siblings' fields along wit hits value(each record/row). Delete the remaining columns like 'State, Age, Apt no,Country,Gender'.
Please tell me what is the correct processor for this and what configuration properties to use in order to achieve this. Thanks
Attaching snapshot for reference.
You can use ConvertRecord for this. Provide the full schema to the CSVReader, and provide the schema with only the fields you want to the CSVRecordSetWriter. If you don't know the input schema (but you know it includes at least the fields you want to send along), you can have the reader Use String Fields From Header, that will create an input schema (using the header line) and assume all fields are strings. However the output schema would have the selected fields along with their types, and ConvertRecord will handle the "deletion" of the other fields, as well as any conversion from String to the desired data type for each of the selected fields.
I think using regular expression is not the best solution: Here is how I should do:
First you need to explore the csv:
$handle = fopen("test.csv", "r")
Map through the data
$data = fgetcsv($handle, 1000, ",")
Create New Header and Array from existed $data with wanted fields
Put new data into new csv.
$fp = fopen('file.csv', 'w');
foreach ($data as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);

Search and Replace Filter in Google Analytics

I'm using filters to consolidate hits to URLS with different variables , into one URL
so:
example.com/abc/123 - 1 hit
example.com/abc/345 - 1 hit
will aggregate consolidate to:
example.come/abc/ - 2 hits
I'm using the SEARCH and REPLACE filter like this :
Search string : /abc/.*
Replace string : /abc/
When I verify this filter, it says no data would be changed. When I change the config to
Search string : /abc/.*
Replace string : /
It reports a major change. It seems the replace string is not right. I basically want to strip the dynamic portion of the URL by replacing any hit that has a dynamic portion with a URL that only has a static portion.
It should work the way you've indicated, but just in case, here's the setup.
Set the Filter Field to "Request URI", and then in the search field use /abc/.*, and in the replace field use /abc/.
Check with the Real-time report, in the Contents report, and also make sure you are doing this in a test view first so that you don't accidentally apply it to your production data.

how to match a field name with another field name

I have two fields that run throughout a website that I would like to match so that when a user inputs a value either of the fields, it will match the other field. I'm using Sitecore Rocks and am trying to use a query to do this.
select ##h1#, ##Title#
from /sitecore/Content/Home//*[##h1# !="##Title#"];
update set ##h1# = ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
What am I missing here?
This article talks about tapping in to the item:saving event which allows you to compare the fields values of the item before and after the changes:
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/Intercepting-Item-Updates-with-Sitecore.aspx
Using this, you can determine which field has been amended, then change the other to match.
I've had to do something similar to this when a new field was added, and we wanted to set the initial value equal to an existing field. It may be a bug in Sitecore Rocks, but I found it would only update a field when a static value was part of the query.
When I ran ##h1# = ##Title#, the query analyzer would return the correct number of items updated, but no values were actually updated. However, ##h1# = '<id>' worked perfectly. After trying a number of things, I found this did what I wanted.
update set ##h1# = '' + ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
I hope that helps.

How do I search a db field for a the string after a "#" and add it to another db field in django

I want to have a content entry block. When a user types #word or #blah in a field, I want efficiently search that field and add the string right after the "#" to a different field as a n entry in a different table. Like what Twitter does. This would allow a user to sort by that string later.
I believe that I would do this as a part of the save method on the model, but I'm not sure. AND, if the #blah already exists, than the content would belong to that "blah"
Can anyone suggest samples of how to do this? This is a little beyond what I'm able to figure out on my own.
Thanks!
You can use regex (re) during save() or whenever to check if your field text contains #(?P<blah>\w+) , extract your blah and and use it for whatever you want .

Django-haystack - highlighting NgramField

I'm trying use highlighting:
self.results = self.results.highlight()
print self.results[0].highlighted['heading'][0]
And this is working perfect if field heading is CharField in search index.
But I need set field heading to NgramField (because I need search start with one letter), and I have issue:
query: old buildings
result: What are old oldbuildings?
What can I do?
Thanks!