473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

parsing text

76
Hi,
Can anyone please tell me how should I be parsing the following text file so that I could retrieve just the text following FUNCTION: and next two lines without the CC?

--------------------- Input text file ---------------------------
CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
CC the hypersensitivity response in plants. Also required for
CC pathogenicity on host plant.
CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.
---------------------------------------------------------------------

This is how I started with:
Expand|Select|Wrap|Line Numbers
  1. if($ln =~ /^CC/){
  2. $ln =~ s/\n//g;
  3. next;
  4. }
  5.  
Thanks
Nov 15 '07 #1
2 982
KevinADC
4,059 Expert 2GB
A very contrived suggestion:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. my $output = '';
  4. while( <DATA> ) {
  5.    if (/\QCC -!- FUNCTION:\E\s*([\s\S]+)/) {
  6.       $output = $1;
  7.       $output .= <DATA>;
  8.       $output .= <DATA>;
  9.       $output =~ s/CC\s+//g;
  10.       last;
  11.    }
  12. }
  13. print $output;
  14. __DATA__
  15. CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
  16. CC the hypersensitivity response in plants. Also required for
  17. CC pathogenicity on host plant.
  18. CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.
Nov 16 '07 #2
idorjee
76
Thanks a lot, KevinADC.


A very contrived suggestion:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. my $output = '';
  4. while( <DATA> ) {
  5.    if (/\QCC -!- FUNCTION:\E\s*([\s\S]+)/) {
  6.       $output = $1;
  7.       $output .= <DATA>;
  8.       $output .= <DATA>;
  9.       $output =~ s/CC\s+//g;
  10.       last;
  11.    }
  12. }
  13. print $output;
  14. __DATA__
  15. CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
  16. CC the hypersensitivity response in plants. Also required for
  17. CC pathogenicity on host plant.
  18. CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.
Nov 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
3
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
7
by: Lucas Tam | last post by:
Hi all, Does anyone know of a GOOD example on parsing text with text qualifiers? I am hoping to parse text with variable length delimiters/qualifiers. Also, qualified text could run onto...
4
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
2
by: JaythePCguy | last post by:
Hi, I am trying to write a text parser to group all nonprintable and control characters, spaces and space delimited words in different groups using Regex class. Using a parsing of...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
1
by: martinsson | last post by:
Hi all! I'm pretty mad about this... dont know what is going on. Im parsing XML file that looks like this: <something> __<item att="something">text<item> __<item...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.