x404.co.uk http://www.x404.co.uk/forum/ |
|
SED/regex help http://www.x404.co.uk/forum/viewtopic.php?f=3&t=5672 |
Page 1 of 1 |
Author: | forquare1 [ Fri Jan 22, 2010 2:10 pm ] | ||||||||||||||||||||||||||||||||||||
Post subject: | SED/regex help | ||||||||||||||||||||||||||||||||||||
Hi all, I have a number of files with a line like this:
I have a statement doing this:
Cat the file, change <> tags around p and /p to [] and tags from h* and /h* to []. However, the statement does this:
The third SED expression is matching everything until the last '>' (just before the [p] tag). How do I make it so it only matches up to the FIRST '>' it comes to? I.E. I want this:
Thanks, Ben |
Author: | forquare1 [ Sat Jan 23, 2010 5:36 pm ] | |||||||||
Post subject: | Re: SED/regex help | |||||||||
Solved ![]() I split the statement into two lines in the end when I cleaned up the script, I also played around and got it to do what I wanted it to:
Simple after I re-read my book on pattern matching, I had missed it the first few times I scanned through it. Now after a few more scripts I've got a legal, up-to-date copy of the book "The Cathedral and the Bazaar" by Eric Raymond, it's a good read ![]() |
Author: | EddArmitage [ Tue Feb 02, 2010 4:27 pm ] | |||||||||
Post subject: | Re: SED/regex help | |||||||||
My turn: It's been a bit of a long day and my brain's clearly missing something obvious. I have a file containing lines of input. I want to use grep to select those that end in a forward slash (ultimately I want to select everything but them, but that's a simple flag). What regexp do I need? I thought I've tried everything obvious:
Edd |
Author: | Nick [ Tue Feb 02, 2010 8:34 pm ] |
Post subject: | Re: SED/regex help |
Argh my head has just imploded. We had to write Sed in C last year. Absolute hell!!!!!!! |
Author: | forquare1 [ Wed Feb 03, 2010 11:51 am ] | |||||||||||||||||||||||||||
Post subject: | Re: SED/regex help | |||||||||||||||||||||||||||
I'd do something like:
|
Author: | EddArmitage [ Wed Feb 03, 2010 11:57 am ] | ||||||||||||||||||||||||||||||||||||
Post subject: | Re: SED/regex help | ||||||||||||||||||||||||||||||||||||
It worked fine in the end as was, when the input was piped straight in from the previous stage. I swear there must be something installed that uses hamsters as line endings on these damn CSC machines! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |