Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 4th, 2011, 08:18 AM
dba_frog's Avatar
dba_frog dba_frog is offline
cave painting, the 1st Opn Src
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Posts: 532 dba_frog Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 3 m 34 sec
Reputation Power: 0
Append to front of newline

Code:
################ PATCH 4487 file activity summary ##########
psrc/146.rpt                     6           7           Yes      Yes    
psrc/146.scr                     12.1.6      12.1.8      Yes      Yes    
psrc/146PD                       22.1.13     22.1.15     Yes      Yes    
############## PATCH 5642.42 file activity summary #######
psrc/146.rpt                     7           8           Yes      Yes    
psrc/146.scr                     12.1.8      12.1.9      Yes      Yes    
psrc/146PD                       22.1.15     22.1.20     Yes      Yes    
############## PATCH 6412.22 file activity summary #######
psrc/146.rpt                     8           9           Yes      Yes    
psrc/146.scr                     12.1.9      12.2.0      Yes      Yes    
psrc/146PD                       22.1.20     22.1.21     Yes      Yes    

output desired
6412.22,psrc/146.rpt,8,9,Yes,Yes    
6412.22,psrc/146.scr,12.1.9,12.2.0,Yes,Yes    
6412.22,psrc/146PD,22.1.20,22.1.21,Yes,Yes


I need to figure out how to pull the Patch number from the first line starting with ####, and pre-pend it to the patch line, ie: prsrc/145.rpt...

Once I do that I can strip the \t in file and get it into a prepped for insert into the table.

How can I get achieve getting the changing patch number and add it to the patch output line?
__________________
Curious by Nature,
Linux by Choice
Lawson ERP reference tools: Lawsuss.com

Reply With Quote
  #2  
Old August 4th, 2011, 10:45 AM
JClasen JClasen is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2007
Posts: 1,513 JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 7 h 10 m 22 sec
Reputation Power: 1422
Please show your own approaches and their results first. Reading your latest posts, I get the feeling, you're just letting us do your work without any own efforts.

Regards, Jens

Reply With Quote
  #3  
Old August 4th, 2011, 12:42 PM
dba_frog's Avatar
dba_frog dba_frog is offline
cave painting, the 1st Opn Src
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Posts: 532 dba_frog Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 3 m 34 sec
Reputation Power: 0
I think that is a little unfair that you want to decide whether or not this forum should help me because you think I am asking to many questions or the wrong type of request.
I've posted a few questions in the last week while working thru some new code ideas and asking for syntax help.

I try to post sample snippets, current results and desired results. If I post a portion of the problem, you don't see the other 70-80% of the problem that I've already fixed. And, 95% of the time I've already Google'd or visited php.net to look for an answer.

If you look at this question I don't ask a multiple part questions, I ask for help trying to tackle the first step in this process. That is not asking you do to my work, I'm asking someone for possible ways to solve this problem. If you can help, then please post an answer or post a link because I have no idea how to pull a piece of a string out of a file and pre-append it to the next line in the file.

And note, the detail of this post is the overall outcome, I in NO WAY asked for a complete answer, I asked
Quote:
how to pull the Patch number from the first line starting with ####, and pre-pend it to the patch line
. That is 1 request for help. And I noted
Quote:
Once I do that I can strip the \t in file and get it into a prepped for insert into the table.
, the follow on steps that I had in mind for this question.

Answer if you want, Plonk if you want, but unless you have the authority to ban me for asking for help I'm going to ask you to keep your comments to yourself.

Thanks!

Reply With Quote
  #4  
Old August 4th, 2011, 03:05 PM
JClasen JClasen is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2007
Posts: 1,513 JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level)JClasen User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 7 h 10 m 22 sec
Reputation Power: 1422
Quote:
Originally Posted by dba_frog
Answer if you want, Plonk if you want, but unless you have the authority to ban me for asking for help I'm going to ask you to keep your comments to yourself

Sorry, but that's a luxury you don't get after continuously ignoring the "How to ask smart questions" guide. You've reached a point, where I'm seriously doubting, I really want to answer your question, since I'm getting the expression, you don't learn from previous answers. The reason why I get this impression is, because you're repeatedly asking very very basic questions without any obvious effort on your part.

That said, let me give you some pointers in the right direction, afterwards the rest is up to you:

- You'll need to deal with your input line by line.
- You'll have to decide what to do, depending on the beginning of your line.
- You're looking for an algorithm, not for a regular expression, since a single regular expression cannot solve your problem.
- Whenever you encounter a new patch set information, store the version info somewhere.
- Whenever you encounter a new file, use its data together with the stored information from the new patch set header.
- Forget the thing with stripping the tabs. Use them as a delimiter, when parsing your file info line.

Regards, Jens

Reply With Quote
  #5  
Old August 8th, 2011, 10:06 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,791 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 14 h 53 m 20 sec
Reputation Power: 6112
You've dealt with loops and arrays in PHP before, as I can see from the various arguments you've had on the topic with our long-standing members.

Jens' advice is correct. Loop line by line. If the line starts with ###, replace the stored prepend number. If not, re-format the line with the prepend number.

The new user guide (which contains information on asking good questions and proper forum etiquette) is right below this message. Yes, you've been on the forums for a while, but you're very combative and this question was pretty much "this is what I start with, this is how I want it to end up, please help." YOU may understand that this is a small set of an overall problem and you're only giving us 10% of it, but we don't. Your answer is "this is not a regular expression question, this is a file parsing question, parse it line by line."

Which language are you familiar with? You've posted in both Perl and PHP. I will move this thread to the appropriate forum for you based on how you'd like to solve it.

-Dan
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Append to front of newline

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap