I am trying to search for few strings from the logline and exclude those lines. If I try with string directly it works but if I read the strings from a config file, it doesn't. The problem is due to the type. Can someone put some light into this in converting the list to string? Code match1 = config.get('sky_messages', 'matches') match = list(match1.split(&quot;,&quot;))  print(match1) print(match) print(type(match1)) print(type(match))  Config File [sky_messages] matches = ['Conviva', 'conviva', 'EDID', 'CONVIVA']  Output ['Conviva', 'conviva', 'EDID', 'CONVIVA'] [&quot;['Conviva'&quot;, &quot; 'conviva'&quot;, &quot; 'EDID'&quot;, &quot; 'CONVIVA']&quot;] &lt;class 'str'&gt; &lt;class 'list'&gt;  How can I get the string as match1?
97052
The typical ConfigParser generated file looks like:  [Section] bar=foo [Section 2] bar2= baz   Now, is there a way to index lists like, for instance:  [Section 3] barList={     item1,     item2 }   Related question:
84742
For the following block of code:  For I = 0 To listOfStrings.Count - 1     If myString.Contains(lstOfStrings.Item(I)) Then         Return True     End If Next Return False   The output is:  Case 1:  myString: C:\Files\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: True   Case 2:  myString: C:\Files3\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: False   The list (listOfStrings) may contain several items (minimum 20) and it has to be checked against a thousands of strings (like myString).  Is there a better (more efficient) way to write this code?
59630
list.txt:    58759__len__2903 58759__len__2903 673957__len__1655 673957__len__1655 3566454__len__1744   seq.fasta:  &gt;58759__len__2903 TTTTCCGTAGAGGAGATCCCTATTTTTAGGTTTGTAAGAGATCATTTT &gt;67777__len__2978 TTTTTAGGTTTGTAAGACCGTAGAG &gt;673957__len__1655 CCCTATTTTTAGGTTTGTAAGGTTTGTAAGACCGTAGAG &gt;3566454__len__1744 GGTTTGTAAGACCGTAGAGGGTTTGTAAGACCGTAGAG   output.fasta:  &gt;58759__len__2903 TTTTCCGTAGAGGAGATCCCTATTTTTAGGTTTGTAAGAGATCATTTT &gt;673957__len__1655 CCCTATTTTTAGGTTTGTAAGGTTTGTAAGACCGTAGAG &gt;3566454__len__1744 GGTTTGTAAGACCGTAGAGGGTTTGTAAGACCGTAGAG   Match line from list.txt (if duplicate line, use only unique line) to seq.fasta and extract the FASTA file as shown in output file.
40669
I want to reverse a regular expression. I.e. given a regular expression, I want to produce any string that will match that regex.  I know how to do this from a theoretical computer science background using a finite state machine, but I just want to know if someone has already written a library to do this. :)  I'm using Python, so I'd like a Python library.  To reiterate, I only want one string that will match the regex. Things like "." or ".*" would make an infinite amount of strings match the regex, but I don't care about all options.  I'm willing for this library to only work on a certain subset of regex.
40934
I have a couple of big text files and in the file UNIQS.txt I have a list of strings to grep from another file. The code I use is  grep -f UNIQS.txt EEP_VSL.uniqs.sam &gt; UNIQ_templates.sam   which does nothing - the file generated is empty. But when I do  grep -F -f UNIQS.txt EEP_VSL.uniqs.sam &gt; UNIQ_templates.sam   it works correctly. This confuses me because I didn't think grep would interpret the entries in UNIQS.txt as regexp patterns without quotes and slashes and so on being in the file (which there aren't). Is it the case in general that if you are getting the patterns from a file then it will automatically think that they are regexp patterns?  Edit: In the UNIQS.txt file, there are newline separated strings of the form  HWI-ST365:215:D0GH0ACXX:2:1101:10034:186783   (called template names) and the file EEP_VSL... tab separated columns, with about 14 columns and the first column is the template name, so basically I want to extract the line corresponding to each template in the file.
113775
I need to select certain lines from the log file and also save them to a text file. I tried the following but none of them are working as expected. The file "todel.txt" shows 0 bytes.  tail -f general.log | grep Some_word &gt; &gt;(tee -a todel.txt)  tail -f general.log | grep Some_word ; tee  todel.txt  tail -f general.log | grep Some_word | tee -a todel.txt
62677
I am writing a Java utility which helps me to generate loads of data for performance testing.  It would be really cool to be able to specify a regex for Strings so that my generator spits out things which match this.  Is there something out there already baked which I can use to do this?  Or is there a library which gets me most of the way there?  Thanks
35663
My controller code is as follows -          for(String resStr : responseArray){             if(resStr.indexOf('r_error_str') != -1){                 responseString += resStr.substring(resStr.indexOf('=') + 1);                  responseString += '\n';             }         }   but when i display this 'responseString ' String using 'apex:outputLabel or apex:outputText or as Exception message '\n' is not converting in new line. Whole String is coming in one line.  Can anyone explain why is this happining
82085
How is it possible to let lstlisting wrap lines?  I've troubles with following block:  \begin{lstlisting}[language=java]  public class MeasureStationControllerV0Test {    MeasureStationControllerV0 controller;   MeasureStation ms = new MeasureStation();    MeasureStationConfiguration config = new MeasureStationConfiguration();      DataServer dataserver = new DataServer();   In the PDF output there is an overflow:    Other code-snippets look horrible too.    So have I to manually wrap them or is listings able to handle that? Why isn't syntax highlighting working?
25827
I needed to find all the files that contained a specific string pattern. The first solution that comes to mind is using find piped with xargs grep:  find . -iname '*.py' | xargs grep -e 'YOUR_PATTERN'   But if I need to find patterns that spans on more than one line, I'm stuck because vanilla grep can't find multiline patterns.
52832
I've often seen people use Perl data structures in lieu of configuration files; i.e. a lone file containing only:  %config = (     'color' =&gt; 'red',     'numbers' =&gt; [5, 8],     qr/^spam/ =&gt; 'eggs' );   What's the best way to convert the contents of these files into Python-equivalent data structures, using pure Python? For the time being we can assume that there are no real expressions to evaluate, only structured data.
64135
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
48268
I have some simple python code that searches files for a string e.g. path=c:\path, where the c:\path part may vary. The current code is:  def find_path(i_file):     lines = open(i_file).readlines()     for line in lines:         if line.startswith("Path="):             return # what to do here in order to get line content after "Path=" ?   What is a simple way to get the text after Path=?
60761
I'm looking for the string foo= in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl &quot;foo=&quot; *  In the directories are also many binary files which match &quot;foo=&quot;. As these results are not relevant and slow down the search, I want grep to skip searching these files (mostly JPEG and PNG images). How would I do that? I know there are the --exclude=PATTERN and --include=PATTERN options, but what is the pattern format? The man page of grep says: --include=PATTERN     Recurse in directories only searching file matching PATTERN. --exclude=PATTERN     Recurse in directories skip file matching PATTERN.  Searching on grep include, grep include exclude, grep exclude and variants did not find anything relevant If there's a better way of grepping only in certain files, I'm all for it; moving the offending files is not an option. I can't search only certain directories (the directory structure is a big mess, with everything everywhere). Also, I can't install anything, so I have to do with common tools (like grep or the suggested find).
20826
In a text file, there is a string "I don't like this".  However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use   f1 = open (file1, "r") text = f1.read()   command to do the reading.  Now, is it possible to read the string in such a way that when it is read into the string, it is "I don't like this", instead of "I don\xe2\x80\x98t like this like this"?  Second edit: I have seen some people use mapping to solve this problem, but really, is there no built-in conversion that does this kind of ANSI to unicode ( and vice versa) conversion?
1888
I want to do something like String.Format("[{0}, {1}, {2}]", 1, 2, 3) which returns:  [1, 2, 3]   How do I do this in Python?
75528
More often that I like to admit I look for a file that contains some strings.  Currently I do:  grep -rl string1 | xargs grep -l string2 | xargs grep -l string3   Is there a tool that does this prettier?  This greps for string1 or string2 or string3.   grep -rl -e string1 -e string2 -e string3   I want files that contain string1 and string2 and string3 but not necessarily on the same line.  Maybe one of the modern greps (ag/ack/rg/sift) can do this?