I have this text  txt = "Local residents o1__have called g__in o22__with reports...";   in which I need to get the list of numbers between each o and __  If I do  txt.match(/o([0-9]+)__/g);   I will get  ["o1__", "o22__"]   But I'd like to have  ["1", "22"]   How can I do that ?
8109
I want to match a portion of a string using a  and then access that parenthesized substring:  var myString = "something format_abc"; // I want "abc"  var arr = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(myString);  console.log(arr);     // Prints: [" format_abc", "abc"] .. so far so good. console.log(arr[1]);  // Prints: undefined  (???) console.log(arr[0]);  // Prints: format_undefined (!!!)   What am I doing wrong?    I've discovered that there was nothing wrong with the regular expression code above: the actual string which I was testing against was this:  "date format_%A"   Reporting that "%A" is undefined seems a very strange behaviour, but it is not directly related to this question, so I've opened a new one, .    The issue was that console.log takes its parameters like a printf statement, and since the string I was logging ("%A") had a special value, it was trying to find the value of the next parameter.
80374
If I have this string:     2+24*48/32   what is the most efficient approach for creating this list:     ['2', '+', '24', '*', '48', '/', '32']
65159
I have a text file which I want to split into 64 unequal parts, according to the 64 hexagrams of the Yi Jing. Since the passage for each hexagram begins with some digit(s), a period, and two newlines, the regex should be pretty easy to write.  But how do I actually split the text file into 64 new files according to this regex? It seems like more of a task for perl. But maybe there's a more obvious way that I'm just totally missing.
33653
I have a text in a text file, where I want everything that is between strings like \{{[} and {]}\} to be deleted - including these strings themselves.  These two string can lie on different lines as well as on the same line. In either case,  on the line on which the beginning \{{[} lies, I don't want the text before, i.e. left, of it to be deleted - and the same holds for the text after {]}\}.  Here is an example: Given a text file with the content   Bla Bla bla bla \{{[} more bla bla even more bla bla bla bla.   A lot of stuff might be here.  Bla bla {]}\} finally done.  Nonetheless, the \{{[} show {]}\} goes on.   the script should return another text file with the content  Bla Bla bla bla  finally done.  Nonetheless, the  goes on.   Unfortunately this simple-looking task turned out to be too difficult for me to do with sed. I'm happy with any solution in any language, as long as I don't have to install anything on my standard linux machine (C and some java is already installed).
118546
Is there a regular expression that matches valid regular expressions?   (I know there are several flavors of regexps. One would do.)
33856
I want to display all the characters in a file between strings "xxx" and "yyy" (the quotes are not part of the delimiters). How can I do that ? For example, if i have input "Hello world xxx this is a file yyy", the output should be " this is a file "
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)))
77300
I want to subtract a constant number from my data to get new data file. For example, I want to subtract  10 from my data.   data.txt  Id  a   b   c   d   e 1   1   2   3   4   5 2   2   3   4   5   6 3   3   4   5   6   7 4   4   5   6   7   8 5   5   6   7   8   9 6   6   7   8   9   10 7   7   8   9   10  11 8   8   9   10  11  12 9   9   10  11  12  13 10  10  11  12  13  14 11  11  12  13  14  15 12  12  13  14  15  16 13  13  14  15  16  17 14  14  15  16  17  18   Required output:  out.txt   Id  a   b   c   d   e 1   -9  -8  -7  -6  -5 2   -8  -7  -6  -5  -4 3   -7  -6  -5  -4  -3 4   -6  -5  -4  -3  -2 5   -5  -4  -3  -2  -1 6   -4  -3  -2  -1  0 7   -3  -2  -1  0   1 8   -2  -1  0   1   2 9   -1  0   1   2   3 10  0   1   2   3   4 11  1   2   3   4   5 12  2   3   4   5   6 13  3   4   5   6   7 14  4   5   6   7   8
37775
Between first occurrence of Cat to next occurrence of Cat, it should create a separate line with delimiter as ",".  File input  as below.  Cat AA BB CC Cat AA-1 BB-1 CC-1   Output expected:  Cat,AA,BB,CC Cat,AA-1,BB-1,CC-1
6643
I am doing something where I realised I wanted to count how many /s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was.  At the moment I'm going with something like:  string source = "/once/upon/a/time/"; int count = source.Length - source.Replace("/", "").Length;   But I don't like it at all, any takers?  I don't really want to dig out RegEx for this, do I?  I know my string is going to have the term I'm searching for, so you can assume that...  Of course for strings where length > 1,  string haystack = "/once/upon/a/time"; string needle = "/"; int needleCount = ( haystack.Length - haystack.Replace(needle,"").Length ) / needle.Length;
5132
Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.
101931
Name, lastname, phone number .This is the text  :   Hace, Apoio, 703-2101  Yoliot, Apostolos, 4222-1124  Jenny,Thano,105-4122   Heriom,Koun, 510-4122   Dekon, Atolo, 502-2522   Feow, R,685-3431   I want to find all lastnames that have 5 characters only   Edit: I tried  egrep -i '[^:]+[a-z]5$' file2    but that doesn't work
112773
I need to be able to take a string like:  '''foo, bar, "one, two", three four'''   into:  ['foo', 'bar', 'one, two', 'three four']   I have an feeling (with hints from #python) that the solution is going to involve the shlex module.
3235
I would like to get the multi pattern match with implicit AND between patterns, i.e. equivalent to running several greps in a sequence:  grep pattern1 | grep pattern2 | ...   So how to convert it to something like?  grep pattern1 &amp; pattern2 &amp; pattern3   I would like to use single grep because I am building arguments dynamically, so everything has to fit in one string. Using filter is system feature, not grep, so it is not an argument for it.    Don't confuse this question with:  grep "pattern1\|pattern2\|..."   This is an OR multi pattern match.
30479
How can I select first occurrence between two patterns including them. Preferably using sed or awk.  I have:  text something P1 something content1 content2 something P2 something text something P1 something content3 content4 something P2 something text   I want the first occurrence of the lines between P1 and P2 (including P1 line and P2 line):  something P1 something content1 content2 something P2 something
17881
I'm trying to retrieve the the matching lines from a file, however the file that has the "index" or list of matches to retrieve also has duplicate entries and I want to print out the duplicates as well.  Example:  File 1 (index file or list of strings to match)  abc tgf abc ggg aaa fff   File 2 (what I want to retrieve for each of the matches in file 1)  Fred   1   3   abc Amy    2   4   ggg Dan    5   6   tgf Mike   9   1   fff Steve  2   1   aaa   My desired result would be (order is not important, just that I match every line):  Fred   1   3   abc Dan    5   6   tgf Fred   1   3   abc Amy    2   4   ggg Steve  2   1   aaa Mike   9   1   fff   I'm familiar and have tried grep as follows, but it does not print the duplicate entries.  grep -Fwf file1.txt file2.txt  Fred   1   3   abc Amy    2   4   ggg Dan    5   6   tgf Mike   9   1   fff Steve  2   1   aaa
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?