We help IT Professionals succeed at work.
Get Started

Python : How write regular expression for Find following

401 Views
Last Modified: 2012-05-11

        pattern = '.{3}\d{3}.{1,3}.{3}\x44)';
        data = re.compile(pattern, line3);
        print(data)       


Find all the Rows which have 'G' from the following list ...

ATOM   2462  CG  LYS F 102      -2.893  40.042  54.306  1.00 40.44           C  
ATOM   2463  CD  LYS F 102      -2.727  39.141  55.517  1.00 54.83           C  
ATOM   2464  CE  LYS F 102      -1.264  38.659  55.654  1.00 66.42           C  
ATOM   2465  NZ  LYS F 102      -0.991  37.789  56.851  1.00 67.89           N  
ATOM   2466  N   ASN F 103      -4.926  39.568  51.170  1.00 38.71           N  
ATOM   2467  CA  ASN F 103      -6.316  39.947  50.958  1.00 50.68           C  
ATOM   2468  C   ASN F 103      -7.335  38.968  51.547  1.00 55.47           C  
ATOM   2469  O   ASN F 103      -7.221  38.707  52.774  1.00 56.08           O  
ATOM   2470  CB  ASN F 103      -6.597  40.317  49.482  1.00 54.91           C  
ATOM   2471  CG  ASN F 103      -6.420  39.160  48.523  1.00 62.17           C  
ATOM   2472  OD1 ASN F 103      -7.299  38.899  47.690  1.00 66.10           O  
ATOM   2473  ND2 ASN F 103      -5.273  38.493  48.590  1.00 62.60           N  
ATOM   2474  OXT ASN F 103      -8.243  38.500  50.816  1.00 63.85           O  
TER    2475      ASN F 103                                                      
ATOM   2476  N   ALA G   1      10.194  19.797  25.657  1.00 42.95           N  
ATOM   2477  CA  ALA G   1       9.591  18.467  25.347  1.00 38.83           C  
ATOM   2478  C   ALA G   1       8.491  18.028  26.312  1.00 37.02           C  
ATOM   2479  O   ALA G   1       7.509  17.436  25.863  1.00 39.99           O  
ATOM   2480  CB  ALA G   1      10.650  17.409  25.225  1.00 44.81           C  
ATOM   2481  N   PRO G   2       8.653  18.254  27.645  1.00 35.04           N  
ATOM   2482  CA  PRO G   2       7.585  17.847  28.578  1.00 32.47           C  
ATOM   2483  C   PRO G   2       6.328  18.542  28.075  1.00 29.91           C  
ATOM   2484  O   PRO G   2       6.438  19.652  27.567  1.00 35.96           O  
ATOM   2485  CB  PRO G   2       8.037  18.466  29.897  1.00 30.68           C  
ATOM   2486  CG  PRO G   2       9.522  18.393  29.801  1.00 28.46           C  
ATOM   2487  CD  PRO G   2       9.794  18.834  28.388  1.00 31.97           C  
ATOM   2488  N   GLN G   3       5.168  17.892  28.142  1.00 29.01           N  

Comment
Watch Question
Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE