Re: sed html tags

2008-08-28 Thread Joseph Olatt
snip

   Hi, I have the string
  
   span  111 /span  span   /span
  
   And i wish to use sed to strip *only* the span  tag and its
   contents... is this possible ? I'm trying this expression, but it
   doesn't work...
  
   sed 's/span [^\(/span\)]+\/span//g' file
  
   is there anything like it ?
  
   I would like to obtain
  
   
  
  
  
   I hope someone can help,
  
   thank you,
  
   siran

If you haven't yet solved the above problem, give the following a try:

sed 's/\(span .*.*\/span\)\(.*\)\(span .*.*\/span\)/\2/'


regards,
joseph

snip
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-28 Thread An
yes, it does work perfectly with the example I gave... the actual file
is some like

... span  111 span www no /span /span  span yyy
 /span   span yyy  /span ...


your command only returns ]# sed 's/\(span
.*.*\/span\)\(.*\)\(span .*.*\/span\)/\2/' file

 


I wish to rip all span xxx .* /span and obtain

...  span yyy  /span  span yyy  /span...


i think sed should be able to do it, but the operator [ ^ (  ) ]* is
not behaving as i think it would... perl does it alright, though : s

thanks,

siran



On Thu, Aug 28, 2008 at 12:49 PM, Joseph Olatt [EMAIL PROTECTED] wrote:
 snip

   Hi, I have the string
  
   span  111 /span  span   /span
  
   And i wish to use sed to strip *only* the span  tag and its
   contents... is this possible ? I'm trying this expression, but it
   doesn't work...
  
   sed 's/span [^\(/span\)]+\/span//g' file
  
   is there anything like it ?
  
   I would like to obtain
  
   
  
  
  
   I hope someone can help,
  
   thank you,
  
   siran

 If you haven't yet solved the above problem, give the following a try:

 sed 's/\(span .*.*\/span\)\(.*\)\(span .*.*\/span\)/\2/'


 regards,
 joseph

 snip

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-28 Thread Joseph Olatt
On Thu, Aug 28, 2008 at 03:04:22PM -0400, An wrote:
 yes, it does work perfectly with the example I gave... the actual file
 is some like
 
 ... span  111 span www no /span /span  span yyy
  /span   span yyy  /span ...
 
 
 your command only returns ]# sed 's/\(span
 .*.*\/span\)\(.*\)\(span .*.*\/span\)/\2/' file
 
  
 
 
 I wish to rip all span xxx .* /span and obtain


If you wish to rip out all span xxx .* /span then the output would
be:

     


If that is what you want, then try the following:

sed 's/span [a-z]*[ 0-9a-z]*\/span//g; s/\/span//g'


But if Perl is already doing the job for you, I think this can be put to
rest.

regards,
joseph



 ...  span yyy  /span  span yyy  /span...
 
 
 i think sed should be able to do it, but the operator [ ^ (  ) ]* is
 not behaving as i think it would... perl does it alright, though : s


snip
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-26 Thread Yuri Pankov
An wrote:
 unfortunately not... see:
 
 # cat file
 span  111 /span  span   /span
 
 # sed -e 's/\/?span[^]*//g' file
 span  111 /span  span   /span
 
 (...nothing happens, the file is returned with no substitutions done)
 
 
 I could do it with a perl script, which basically does what i would expect
 sed would do:
 
 # cat pscript.pl
 #!/usr/bin/perl -w
 $text = span  111 /span    span   /span span 
 111 /spanspan   /span;
 $text =~ s/span x[^]*[^\(\/span\)]*[\s]*\/span[\s]*//g;
 print $text . \n

$text =~ s#span .*?/span\s*##g;

 # perl pscript.pl
  span   /span span   /span
 
  span xxx . /span  is removed... but i don't seem to be able to do
 it with sed... : (

regexps in sed are greedy and, sadly, you can't use *? as quantifier.
try the following (adding characters that can be inside your ''
tags, of course):
sed 's#span [ a-zA-Z0-9]*/span[ ]*##g'

 Im on fedora c9, maybe that's the problem ?
 
 siran
 
 
 On Mon, Aug 25, 2008 at 8:35 PM, Paul A. Procacci [EMAIL PROTECTED]wrote:
 
 siran wrote:

 Hi, I have the string

 span  111 /span  span   /span

 And i wish to use sed to strip *only* the span  tag and its
 contents... is this possible ? I'm trying this expression, but it
 doesn't work...

 sed 's/span [^\(/span\)]+\/span//g' file

 is there anything like it ?

 I would like to obtain

 



 I hope someone can help,

 thank you,

 siran
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]


 sed -E 's/\/?span[^]*//g'

 Myabe that's what you want?



HTH,
Yuri
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-26 Thread An
Well, thanks, Yuri !

That worked much better than all that i had done ! But i have the problem
that I don't know what characters to expect... accents, ñ, etc... So i
really need a get everything between the span  and the first
/span...

Regarding perl, it is perfect ! thanks !

The ? is critical ! Is it what makes what makes the .* non greedy ?


Thanks,

An M


On Tue, Aug 26, 2008 at 1:53 AM, Yuri Pankov [EMAIL PROTECTED] wrote:

 An wrote:
  unfortunately not... see:
 
  # cat file
  span  111 /span  span   /span
 
  # sed -e 's/\/?span[^]*//g' file
  span  111 /span  span   /span
 
  (...nothing happens, the file is returned with no substitutions done)
 
 
  I could do it with a perl script, which basically does what i would
 expect
  sed would do:
 
  # cat pscript.pl
  #!/usr/bin/perl -w
  $text = span  111 /span    span   /span span
 
  111 /spanspan   /span;
  $text =~ s/span x[^]*[^\(\/span\)]*[\s]*\/span[\s]*//g;
  print $text . \n

 $text =~ s#span .*?/span\s*##g;

  # perl pscript.pl
   span   /span span   /span
 
   span xxx . /span  is removed... but i don't seem to be able to
 do
  it with sed... : (

 regexps in sed are greedy and, sadly, you can't use *? as quantifier.
 try the following (adding characters that can be inside your ''
 tags, of course):
 sed 's#span [ a-zA-Z0-9]*/span[ ]*##g'

  Im on fedora c9, maybe that's the problem ?
 
  siran
 
 
  On Mon, Aug 25, 2008 at 8:35 PM, Paul A. Procacci 
 [EMAIL PROTECTED]wrote:
 
  siran wrote:
 
  Hi, I have the string
 
  span  111 /span  span   /span
 
  And i wish to use sed to strip *only* the span  tag and its
  contents... is this possible ? I'm trying this expression, but it
  doesn't work...
 
  sed 's/span [^\(/span\)]+\/span//g' file
 
  is there anything like it ?
 
  I would like to obtain
 
  
 
 
 
  I hope someone can help,
 
  thank you,
 
  siran
  ___
  freebsd-questions@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-questions
  To unsubscribe, send any mail to 
  [EMAIL PROTECTED]
 
 
  sed -E 's/\/?span[^]*//g'
 
  Myabe that's what you want?
 


 HTH,
 Yuri

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-25 Thread Paul A. Procacci

siran wrote:

Hi, I have the string

span  111 /span  span   /span

And i wish to use sed to strip *only* the span  tag and its
contents... is this possible ? I'm trying this expression, but it
doesn't work...

sed 's/span [^\(/span\)]+\/span//g' file

is there anything like it ?

I would like to obtain





I hope someone can help,

thank you,

siran
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]
  

sed -E 's/\/?span[^]*//g'

Myabe that's what you want?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sed html tags

2008-08-25 Thread An
unfortunately not... see:

# cat file
span  111 /span  span   /span

# sed -e 's/\/?span[^]*//g' file
span  111 /span  span   /span

(...nothing happens, the file is returned with no substitutions done)


I could do it with a perl script, which basically does what i would expect
sed would do:

# cat pscript.pl
#!/usr/bin/perl -w
$text = span  111 /span    span   /span span 
111 /spanspan   /span;
$text =~ s/span x[^]*[^\(\/span\)]*[\s]*\/span[\s]*//g;
print $text . \n

# perl pscript.pl
 span   /span span   /span

 span xxx . /span  is removed... but i don't seem to be able to do
it with sed... : (


Im on fedora c9, maybe that's the problem ?

siran


On Mon, Aug 25, 2008 at 8:35 PM, Paul A. Procacci [EMAIL PROTECTED]wrote:

 siran wrote:

 Hi, I have the string

 span  111 /span  span   /span

 And i wish to use sed to strip *only* the span  tag and its
 contents... is this possible ? I'm trying this expression, but it
 doesn't work...

 sed 's/span [^\(/span\)]+\/span//g' file

 is there anything like it ?

 I would like to obtain

 



 I hope someone can help,

 thank you,

 siran
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]


 sed -E 's/\/?span[^]*//g'

 Myabe that's what you want?

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]