LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-25-2009, 01:00 PM   #16
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Original Poster
Rep: Reputation: 16

Guys I have another problem, i think sed can do that

input (all in one line):
Code:
SITA<br>_________<br><span class="foto">FOTO: ilustračné foto SITA_AP<br><br><span class="datum">Sobota 24. októbra&nbsp;2009</span><br clear="left">
desired output
Code:
2009 Sobota 24. októbra
tried this
Code:
cat mikus.html | sed -n 's/"datum">\([a-zA-Z][a-zA-Z]* [0-9][0-9]*\. [a-zA-Z][a-zA-Z]*\)&[a-zA-Z][a-zA-Z]*;\([0-9][0-9][0-9][0-9]\)/\2 \1/gp'

also extended regexps

cat mikus.html | sed -nr 's/"datum">([a-zA-Z][a-zA-Z]* [0-9][0-9]*\. [a-zA-Z][a-zA-Z]*)&[a-zA-Z][a-zA-Z]*;([0-9][0-9][0-9][0-9])/\2 \1/gp'
but both returns the same output
Code:
SITA<br>_________<br><span class="foto">FOTO: ilustračné foto SITA_AP<br><br><span class=2009 Sobota 24. októbra</span><br clear="left">

I tried same regexp (without memory of course) in grep an seems work
Code:
grep -o '"datum">[a-zA-Z][a-zA-Z]* [0-9][0-9]*\. [a-zA-Z&][A-Za-z&]*;[0-9][0-9][0-9][0-9]' mikus.html 
"datum">Sobota 24. októbra&nbsp;2009
What I am doing wrong with sed ? Thank you all
 
Old 10-25-2009, 07:07 PM   #17
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
awk
Code:
# awk -vRS='</span>' '{gsub(/.*>|&nbsp;/,"")}1' file
Sobota 24. októbra2009
 
  


Reply

Tags
replace, sed



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
commit interval 5 seconds mscorsese Linux - Newbie 1 10-01-2009 06:52 PM
copying between interval scofiled83 Programming 5 04-04-2009 08:34 PM
Using grep with interval expression... Chikne Slackware 2 04-13-2007 11:04 AM
Log netstat at interval DaHoe Linux - Newbie 4 11-06-2006 02:11 AM
hid interval patch some Linux - Newbie 5 12-04-2003 06:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration