473,461 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to extract out the matched line of a txt file?

7 Nibble
I have a special content txt file like this,



Expand|Select|Wrap|Line Numbers
  1.  
  2. == desc.xxx >>>
  3. 11111
  4. 2222
  5. 333
  6. == desc.xxx <<<
  7. 4
  8. 555
  9. 666
  10. zzz
  11. == desc.yyy >>>
  12. rrr\
  13. == desc.yyy <<<
  14. ttt
  15. iii
  16. ppp
  17. ooo
  18. == desc.zzz >>>
  19. lll
  20. bbhhgfc
  21.  
  22. == desc.zzz <<<
  23.  

my requirement is extract out the matched lines of the text. I want get the below result:
Expand|Select|Wrap|Line Numbers
  1. {
  2.   "desc:xxx": {
  3.     "start": 2,
  4.     "end": 6
  5.   },
  6.   "desc.yyy": {
  7.     "start": 11,
  8.     "end": 13
  9.   },
  10.   "desc.zzz": {
  11.     "start": 18,
  12.     "end": 22
  13.   },
  14.   "undefined": [
  15.     {
  16.       "start": 1,
  17.       "end": 1
  18.     },
  19.     {
  20.       "start": 7,
  21.       "end": 10
  22.     },
  23.     {
  24.       "start": 14,
  25.       "end": 17
  26.     }
  27.   ]
  28. }
  29.  
I searched google, but don't find a solution about this.
Dec 31 '22 #1
0 2707

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

Similar topics

1
by: ash | last post by:
My input file is something like this <DB> <E> <TAG1><!]></TAG1> <TAG2><!]></TAG2> <TAG3><!]></TAG3> </E> <E> <TAG1><!]></TAG1>
9
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and...
0
by: Andy | last post by:
I'm trying to list a portion of an XML file onto a web page in a datagrid. Showing the whole XML file is no problem, but I'm having trouble working out how to show a specific extract. I'm sure this...
8
by: nick | last post by:
Hi all can any one please tell me what is wrong in this code?? I'm new to deal with text files and extract data. i'm trying to look for data in a text file (3~4 pages) some lines start with a...
1
by: rsj | last post by:
Hi! I have a large text file consisting of more than 1000 lines. The pattern for the text file is: xxxxx -- -- -- --
2
by: f0zzyNUE | last post by:
hi, i need to extract a cabinet file (.cab) within a .net application ... are there some classes in the .net framework that support extraction of these archive files or can somebody recommend a...
5
by: pinpe | last post by:
Hi, I have problem of filtering a log file from my perl script. This is the file content of the file pinpe.csv: 2009-06-16 2009-01-29 2009-06-02 2008-03-05
6
by: pramodkh | last post by:
Hi All Today only i joined this group. need ur help. Here goes my question: Is there any simple way to match for a particular pattern ( with start and end delimitters) and extract the matched...
1
by: jewel87 | last post by:
Hi everyone, I need to check for a substring in each line of a TMemo, how can I get each line separately? I'm using this method now: int found; for (int i=1; i<MemoLines; i++) ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.