The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: html tags
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-28-2007
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,635
Quote:
Originally Posted by dunryc View Post
the data i need to grab is from between the new tags these are always on the source what ever the uses query.
There are two different cases to be considered: the starting and ending tags are on the same line or they are on different lines:


Code:
Example

<new>This is the text to catch</new>

<new>
This is some text
to catch</new>

Both can be matched by simple regular expressions. For each regexp i give the matched portion in blue:


Code:
sed -n 's/.*<new>\(.*\)<\/new>.*/\1/p'

blabla <new>text to match</new> blabla

sed -n '/<new>/,/<\/new>/ {
               s/.*<new>//
               s/<\/new>.*//
               /^$/d
               p
               }'

blabla <new>text
to
match</new> blabla

bakunin