Need to find a preg_match pattern for the phone numbers below (a mixture of more than one, have kept all in one var), am getting the one preceded with 'Tel,Toll Free' but not the one on new line..looking for some help..or sugestion  preg_match_all('/((.*)|\s)?\s*?\:\s*?([0-9 A-Z a-z \-\+\.\,\/\(\)(Ext))]*)/i  $phAr="Tel: 813-227-4500(+787 45 55 56)  Tel : 002-6598-6554 (+98-214-214)  (509) 878 9856 658  Tel: 888 (408) 546-777 Ext 1122 or 1133  Tel: 888 (408) 546-000 (TollFree)   Toll Free: 1-125-PYS-PYS(145-547-554-45)  Tel: +88 555-988 (408)/(999)  Toll: 1-125-PYS-4YOU (Mr. Toran) Toll Free: 1-125-PYS-PYS  +9999-888-66655 (258)  Tel: 813-227-4500 Ext 1254 / 8525  Phone : (855) 834-7487   +1-9999-888-66655-PYS-PYS  (+98-987-658498)  99-408-546-099 (Mr. Reigh O) Address1 Part1 8760 North Address2. Address2 00 9999 ";
2898
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:   1-234-567-8901 1-234-567-8901 x1234 1-234-567-8901 ext1234 1 (234) 567-8901 1.234.567.8901 1/234/567/8901 12345678901   I'll answer with my current attempt, but I'm hoping somebody has something better and/or more elegant.
96053
Is there a formula or script that will match sub-strings from one column in another column and return the full value of the sub-string match? e.g.  Input  COL_a            COL_b name             201284_blah_year.ext address          407284_blah_name.xml journal          501283_blah_journal_entries.ott journal_entries  701284_blah_type.dat year             401184_blah_journal.ext type             301287_blah_address.txt   Desired output  COL_a            COL_b name             407284_blah_name.xml  address          301287_blah_address.txt journal          401184_blah_journal.ext  journal_entries  501283_blah_journal_entries.ott  year             201284_blah_year.ext  type             701284_blah_type.dat
115440
Simply said, I just can't find a way to match a variable against some pattern containing spaces.  Here is what I expected to work (echo 'ok' string)  item='foobar baz' pat=".+bar baz" if [[ "$item" =~ "$pat" ]] ; then     echo ok fi   Adding/removing quotes around $pat does not seem to make any difference. I get those two erros below:  bash: conditional binary operator expected bash: syntax error near `~='   Could someone please help me pointing out what I am doing wrong here ? Should I put the pattern right away (without any quotes/double quotes, nor variable reference) ? If that is the case, then how can I put spaces in ? (using reg-exp matching, not an alternative)  Thank you !
3909
Is there a way to achieve the equivalent of a  in javascript regular expressions?  I need to match a string that does not start with a specific set of characters.  It seems I am unable to find a regex that does this without failing if the matched part is found at the beginning of the string.  Negative lookbehinds seem to be the only answer, but javascript doesn't have one.  EDIT: This is the regex that I would like to work, but it doesn't:  (?&lt;!([abcdefg]))m  So it would match the 'm' in 'jim' or 'm', but not 'jam'
372
What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it.
90937
I am making a regex expression in which I only want to match wrong tags like: &lt;p&gt; *some text here, some other tags may be here as well but no ending 'p' tag* &lt;/p&gt;   &lt;P&gt;Affectionately Inscribed &lt;/P&gt;&lt;P&gt;TO &lt;/P&gt;&lt;P&gt;HENRY BULLAR, &lt;/P&gt;&lt;P&gt;(of the western circuit)&lt;P&gt;PREFACE&lt;/P&gt;   In the above same text I want to get the result as  &lt;P&gt;(of the western circuit)&lt;P&gt; and nothing else should be captured. I'm using this but its not working:  &lt;P&gt;[^\(&lt;/P&gt;\)]*&lt;P&gt;   Please help.
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.
20352
Is it possible to detect a valid regular expression with another regular expression?  If so please give example code below.
34906
I have this pattern:  1 11 21 1211 111221   I'm guessing it's a fibo pattern, been at it for hours now. Anyone know?
62549
I'm having a bit of trouble getting a Python regex to work when matching against text that spans multiple lines. The example text is ('\n' is a newline)  some Varying TEXT\n \n DSJFKDAFJKDAFJDSAKFJADSFLKDLAFKDSAF\n [more of the above, ending with a newline]\n [yep, there is a variable number of lines here]\n \n (repeat the above a few hundred times).   I'd like to capture two things: the 'some_Varying_TEXT' part, and all of the lines of uppercase text that comes two lines below it in one capture (i can strip out the newline characters later).  I've tried with a few approaches:  re.compile(r"^&gt;(\w+)$$([.$]+)^$", re.MULTILINE) # try to capture both parts re.compile(r"(^[^&gt;][\w\s]+)$", re.MULTILINE|re.DOTALL) # just textlines   and a lot of variations hereof with no luck. The last one seems to match the lines of text one by one, which is not what I really want. I can catch the first part, no problem, but I can't seem to catch the 4-5 lines of uppercase text. I'd like match.group(1) to be some&#95;Varying&#95;Text and group(2) to be line1+line2+line3+etc until the empty line is encountered.  If anyone's curious, its supposed to be a sequence of aminoacids that make up a protein.
82950
I'm in the process of moving an application from PHP to Java and there is heavy use of regular expressions in the code.  I've run across something in PHP that doesn't seem to have a java equivalent:  preg_replace_callback()   For every match in the regex, it calls a function that is passed the match text as a parameter.  As an example usage:  $articleText = preg_replace_callback("/\[thumb(\d+)\]/",'thumbReplace', $articleText); # ... function thumbReplace($matches) {    global $photos;    return "&lt;img src=\"thumbs/" . $photos[$matches[1]] . "\"&gt;"; }   What would be the ideal way to do this in Java?
15969
Is there any way I can search based on the last three digits of a file name?  I have a file with many invoices that are easy to reference with the last three numbers. Is there any way I can search something like *765 to search for ends with 765  Another example.. sometimes files are prefixed with a 0, sometimes not.. 093241251 vs 93241251 and if I just search 93241251 it will not find the 0 prefix version
111512
I am using this method to try find a match, in an example:  Regex.Match("A2-TS-OIL", "TS-OIL", RegexOptions.IgnoreCase).Success;   I got a true result. I am confused. I think this should return false since there is no special characters in the pattern. If I use ".+TS-OIL", true should be returned (. for any and + for more than 1). How should I do to get what I need?
13500
Input file1 is:  dog 123 4335 cat 13123 23424  deer 2131 213132 bear 2313 21313   I give the match the  pattern from in other file ( like dog 123 4335 from   file2).  I match the pattern of the line is dog 123 4335 and after printing all lines without match line my output is:   cat 13123 23424 deer 2131 213132 bear 2313 21313   If only use without address of line only use the pattern, for example 1s how to  match and  print the lines?
23363
Given the URL (single line):   How can I extract the following parts using regular expressions:   The Subdomain (test) The Domain (example.com) The path without the file (/dir/subdir/) The file (file.html) The path with the file (/dir/subdir/file.html) The URL without the path () (add any other that you think would be useful)   The regex should work correctly even if I enter the following URL:    http://example.example.com/example/example/example.html
100821
It seems I am misusing grep/egrep.   I was trying to search for strings in multiple line and could not find a match while I know that what I'm looking for should match. Originally I thought that my regexes were wrong but I eventually read that these tools operate per line (also my regexes were so trivial it could not be the issue).  So which tool would one use to search patterns across multiple lines?
123662
Is there any way to use grep to search for entry matching multiple patterns in any order using single condidion?  As showed in  for multiple patterns i can use   grep -e 'foo.*bar' -e 'bar.*foo'   but i have to write 2 conditions here, 6 conditions for 3 patterns and so on... I want to write single condition if possible. For finding patterns in any order you can suggest to use:   grep -e 'foo' | grep -e 'bar' # at least i do not retype patterns here   and this will work but i would like to see colored output and in this case only bar will be highlighted.  I would like to write condition as easy as   awk '/foo/ &amp;&amp; /bar/'   if it is possible for grep (awk does not highlight results and i doubt it can be done easily).  agrep can probably do what i want, but i wonder if my default grep (2.10-1) on ubuntu 12.04 can do this.