string-search

How to return a string if a re.findall finds no match

自古美人都是妖i 提交于 2021-01-28 07:26:50
问题 I am writing a script to take scanned pdf files and convert them into lines of text to enter into a database. I use re.findall to get matches from a list of regular expressions to get certain values from the tesseract extracted strings. I am having trouble when a regular expression can't find a match I want it to return "Error." So I can see that there is a problem. I have tried a handful of if/else statements but I can't seem to get any to notice the None value. from wand.image import Image

Does the phrase search operator <-> work with JSONB documents or only relational tables?

一曲冷凌霜 提交于 2020-01-05 08:10:59
问题 Does the phrase search operator <-> work with JSONB documents or only relational tables in PostgreSQL? I haven't experimented with this yet, as I haven't yet set up Postgres hosting. The answer to this question will help determine what database and what tools I will be using. I found this sample code at: https://compose.com/articles/mastering-postgresql-tools-full-text-search-and-phrase-search/: SELECT document_id, document_text FROM documents WHERE document_tokens @@ to_tsquery('jump <->

Matching multiple strings to one long string using patterns

隐身守侯 提交于 2020-01-04 06:51:13
问题 I have a line of DNA code and I'm trying to use a Java regex expression to match the codon (3 letter sequence) to an amino acid. Below is an example of one of the patterns: Pattern A = Pattern.compile(("gct")||("gcc")||("gca")||("gcg")); This syntax does not seem to be working with or without the round brackets. Ultimately the aim of the code is to count the number of times the amino acid is found in the DNA string, and since there are 20 or so amino acids I have that many patterns. Can

Replace repeating strings in a string

£可爱£侵袭症+ 提交于 2020-01-03 13:31:23
问题 I'm trying to find (and replace) repeated string in a string. My string can look like this: Lorem ipsum dolor sit amet sit amet sit amet sit nostrud exercitation amit sit ullamco laboris nisi ut aliquip ex ea commodo consequat. This should become: Lorem ipsum dolor sit amet sit nostrud exercitation amit sit ullamco laboris nisi ut aliquip ex ea commodo consequat. Note how the amit sit isn't removed since its not repeated. Or the string can be like this: Lorem ipsum dolor sit amet () sit amet

Create macro to search Worksheet for list of strings and highlight the row

瘦欲@ 提交于 2019-12-24 11:46:56
问题 Can someone help me create a macro that will search an Excel worksheet for a list of 30 strings (e.g., SV-32488r1 , SV-33485r1 ) and highlight the Row when found? I am using Office 2010. I am not a Excel or VBA wiz so I have no idea where to start. The searches I have found only allow me to search for one string. Thank you so much in advance. 回答1: Public Sub HighlightListedValues() Dim strConcatList As String Dim cell As Range 'Creates a string concatenating your list of strings, separated by

what's the fastest way to scan a very large file in java?

北战南征 提交于 2019-12-21 04:43:13
问题 Imagine I have a very large text file. Performance really matters. All I want to do is to scan it to look for a certain string. Maybe I want to count how many I have of those, but it really is not the point. The point is: what's the fastest way ? I don't care about maintainance it needs to be fast. Fast is key. 回答1: For a one off search use a Scanner, as suggested here A simple technique that could well be considerably faster than indexOf() is to use a Scanner, with the method

Case insensitive string search in golang

白昼怎懂夜的黑 提交于 2019-12-18 11:18:33
问题 How do I search through a file for a word in a case insensitive manner? For example If I'm searching for UpdaTe in the file, if the file contains update, the search should pick it and count it as a match. 回答1: strings.EqualFold() can check if two strings are equal, while ignoring case. It even works with Unicode. See http://golang.org/pkg/strings/#EqualFold for more info. http://play.golang.org/p/KDdIi8c3Ar package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.EqualFold(

MySQL: How to search multiple tables for a string existing in any column

喜你入骨 提交于 2019-12-17 15:38:35
问题 How can I search for in table_a table_b table_c , which have a random number of columns for a string? I know this is not proper sql but it would be something like: SELECT * FROM users, accounts, something_else WHERE ->ANY COLUMN CONTAINS 'this_string'<- Ty in advance for SO community 回答1: Add fulltext indexes to all of the string columns in all of those tables, then union the results select * from table1 where match(col1, col2, col3) against ('some string') union all select * from table2

Change foreign characters to their roman equivalent

∥☆過路亽.° 提交于 2019-12-17 07:21:46
问题 I am using php and I was wondering if there was a predefined way to convert foreign characters to their non-foreign alternatives. Characters such as ê, ë, é all resulting to 'e' . I'm looking for a function that would take a string and return it without the special characters. Any ideas would be greatly appreciated! 回答1: After failing to find suitable convertors I created my own collection that suits my needs including my favorite Cyrillic conversion that by default has numerous variations.

Most effective code to search character in string

为君一笑 提交于 2019-12-14 04:23:54
问题 Let's say we have a given string of chars DataString DB 'AGIJKSZ', 0FFH ; What would be the most time-effective procedure to find let's say J in it? By time-effective I mean least amount of clock ticks. It's a x86 processor with these instruction sets: MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, EM64T, VT-x, AES, AVX, AVX2, FMA3, TSX Let's assume that both string and searched character can be changed but only via editing the code, and we're always looking for a single character. The string