Searching (x,y) pair in sequence
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Why not search for the pair you want? Also, you can use \s to match whitespace. import re
def find_pair(x, y, mystring):
return re.findall(r'\(\s*?%d,\s*?%d\s*?\)+' % (x, y), mystring);
print find_pair(2, 4, "(3,4) , (2, 4),(5,4), (2,3), ")
|
Searching by a Sequence Numbers would be faster than searching a string?
Date : March 29 2020, 07:55 AM
may help you . Overall, searching for numeric equality will probably be faster than a string comparison, helped also because the size of the documents searched will be smaller. It's hard to say though whether the speed increase will be significant, since the performance will be impacted by a number of factors that might dwarf a string vs integer comparison - for example how the size increase of the documents affects what's in RAM, or whether doing another query for the string each request is slower. Indexes will be much faster.
|
Searching log file based on pattern, then searching in reverse for specific text
Date : March 29 2020, 07:55 AM
hope this fix your issue If you filter the log to only show lines that match "ERROR" or "Import #" then you can use the index of the ERROR line to retrieve the previous line. This line should be the import line as we are filtering the log only to show imports and errors. This is making an assumption based on the log you have sent. It is possible this may not work if the log contains other lines that match these patterns that are not relevant to our lookup. # Get content from log file where line matches 'ERROR' or 'Import #'
$log = gc c:\log.txt | ? { $_ -cmatch 'Import #' -or $_ -cmatch 'ERROR' }
# For each line in log file
foreach($l in $log)
{
# If it matches ERROR
if($l -cmatch 'ERROR')
{
# Return the previous line
$log[$log.IndexOf($l)-1]
}
}
|
How to specify searching sequence in fields in solr?
Tag : solr , By : Ohad Barzilay
Date : March 29 2020, 07:55 AM
|
How can I add some text after some sequence of text if this sequence matches certain criteria using Shell script?
Tag : bash , By : acolomba
Date : March 29 2020, 07:55 AM
around this issue If Perl is acceptable for you, it will be easy to do what you want because Perl is good at handling mult-line regular expressions. Then how about: perl -e '
while (<>) {
$text .= $_;
}
$add = "\nAFFECTED_ROWS := AFFECTED_ROWS + SQL%ROWCOUNT;";
$text =~ s/^UPDATE[\s\S]+?SET[\s\S]+?;/$&$add/mg;
$text =~ s/^DELETE[\s\S]+?FROM[\s\S]+?;/$&$add/mg;
$text =~ s/^INSERT[\s\S]+?INTO[\s\S]+?;/$&$add/mg;
$text =~ s/^MERGE[\s\S]+?INTO[\s\S]+?(WHEN MATCHED THEN|WHEN NOT MATCHED)[\s\S]+?(UPDATE|INSERT|DELETE)[\s\S]+?;/$&$add/mg;
print $text;
' inputfile
|