LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 10-25-2009, 02:00 PM   #16
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 64
Thanked: 1

Original Poster

[Log in to get rid of this advertisement]
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
linux wakatana is offline     Reply With Quote
Old 10-25-2009, 08:07 PM   #17
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 1,814
Blog Entries: 5
Thanked: 115
awk
Code:
# awk -vRS='</span>' '{gsub(/.*>|&nbsp;/,"")}1' file
Sobota 24. októbra2009
linuxfedora ghostdog74 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 07:52 PM
copying between interval scofiled83 Programming 5 04-04-2009 09:34 PM
Using grep with interval expression... Chikne Slackware 2 04-13-2007 12:04 PM
Log netstat at interval DaHoe Linux - Newbie 4 11-06-2006 03:11 AM
hid interval patch some Linux - Newbie 5 12-04-2003 07:28 AM


All times are GMT -5. The time now is 08:02 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration