In my case I want to find (using python regex) all lines not containing the words "error" or "empty". In code:       varformals    : PAR_OPEN PAR_CLOSE                                                    {}             | PAR_OPEN varform PAR_CLOSE                                            {}   /* error / | error PAR_CLOSE                                                     {}   / error / | error varform PAR_CLOSE                                             {}   / error */ | PAR_OPEN error PAR_CLOSE                                                {}   ;
5915
I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?   Input:  hoho hihi haha hede   Code:  grep "&lt;Regex for 'doesn't contain hede'&gt;" input   Desired output:  hoho hihi haha
13336
grep returns just the line where it matched the regex and often what I want to really see is a few (say 2) lines above and below the matched one. Is there a simple way to achieve it?  EDIT: OS: Ubuntu based Bodhi Linux.  As mentioned in comments, -C does not work in vanilla but its GNU grep in my case.
86509
I am trying to find data from files using grep, but grep usually prints out the filename as well as the line where the term is found.  In this case, I am looking for a special regexp and I want grep to print all items matching the regexp, not the line or the filename. In other words, I want to see only the matched regular expression.
43285
findstr /v "black"  File1.txt   Above DOS command will display content of 'File1.txt' which are not matching string "black".  How to modify this command , if I need to filter words "black" and "white" ?
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=?
123543
I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.  I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them with a common character. Then compare the two strings str1 and str2. I am not looking for such implementations, but like to know whether there are any .Net framework classes that can take care of this. Seems like a common need, but I couldn't find any such method.  For example:  string str1 = "ABC-EFG";     string str2 = "ABC*EFG";   The two strings must be declared equal.  Thanks!
18554
I'm new to regular expressions and would appreciate your help.  I'm trying to put together an expression that will split the example string using all spaces that are not surrounded by single or double quotes. My last attempt looks like this: (?!") and isn't quite working. It's splitting on the space before the quote.  Example input:   This is a string that "will be" highlighted when your 'regular expression' matches something.   Desired output:  This is a string that will be highlighted when your regular expression matches something.   Note that "will be" and 'regular expression' retain the space between the words.
96570
If "errored" is not a valid word, then how should I say:     The program errored at line 44   I guess I could say:     The program threw an error at line 44   But why is "errored" wrong? Is there a better alternative?
37476
What is the easiest way to match non-ASCII characters in a regex? I would like to match all words individually in an input string, but the language may not be English, so I will need to match things like ü, ö, ß, and ñ. Also, this is in Javascript/jQuery, so any solution will need to apply to that.
1430
I want to check whether Value1 below contains "abc" within the first X characters. How would you check this with an if statement?  var Value1 = "ddabcgghh";  if (Value1.Contains("abc")) {     found = true; }   It could be within the first 3, 4 or 5 characters.
66091
I'm trying to use grep to show only lines containing either of the two words, if only one of them appears in the line, but not if they are in the same line.  So far I've tried  grep pattern1 | grep pattern2 | ... but didn't get the result I expected.
55644
I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.)  I realize that I could .match() substrings with a Regex, but that doesn't solve nesting /*, or having a // inside a /* */.  Ideally, I would prefer a non-naive implementation that properly handles awkward cases.
30572
Is there any tool that can get lines which file A contains, but file B doesn't? I could make a little simple script with, e.g, perl, but if something like that already exists, I'll save my time from now on.
9861
How can I use Unicode-aware regular expressions in JavaScript?  For example, there should be something akin to \w that can match any code-point in Letters or Marks category (not just the ASCII ones), and hopefully have filters like [[P*]] for punctuation, etc.
111242
I have a , and I'm trying to match it to a regular expression to pull out some groups. The problem I'm having is that the URL can either end or continue with a "/" and more URL text. I'd like to match URLs like this:        But not match something like this:      So, I thought my best bet was something like this:    /(.+)/(\d{4}-\d{2}-\d{2})-(\d+)[/$]   where the character class at the end contained either the "/" or the end-of-line. The character class doesn't seem to be happy with the "$" in there though. How can I best discriminate between these URLs while still pulling back the correct groups?
5414
I need a regular expression to select all the text between two outer brackets.  Example: some text(text here(possible text)text(possible text(more text)))end text  Result: (text here(possible text)text(possible text(more text)))
37654
I want to remove all empty lines from a file. Even if the line contains spaces or tabs it should also be removed.