|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
First of all, please have mercy on me. I am not a noob to programming, but I am about as noob as you can get with regex. That being said, I have a problem. I've got a string that looks something like this: Code:
Publication - Bob M. Jones, Tony X. Stark, and Fred D. Man, \"Really Awesome Article Title Here,\" Journal of Awesome People and Stuff, vol. 139, no. 2, October 15, 1990,1,1, pp. 381-391. And I want to format it so that it looks like this: Code:
<h4><ul><li>\"Really Awesome Article Title Here,\"<br/><small>- Bob M. Jones, Tony X. Stark, and Fred D. Man<br/>- Journal of Awesome People and Stuff, vol. 139, no. 2, October 15, 1990,1,1, pp. 381-391.</small></li></ul></h4> I've been trying to figure out 'sed', but for the life of me I can't understand regular expressions. All I was able to come up with was this: Code:
sed 's_Publication -\(.*\), \(".*"\)\( *\.\)_<h4><ul><li>\2<br/><small>- \1<br/>-\3</small></li></ul></h4>_g' < $infile > $outfileBut that doesn't work at all, and it probably has as many syntax errors as possible. I realize that it may seem that I'm lazy and just want somebody to do this for me, but I am here to learn! Last edited by radoulov; 06-01-2012 at 05:06 PM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Ok, I managed to get it. Found out that the text editor I started using a couple days ago (TextWrangler, on Mac OS X) has support for grep built in. Searched for this: Code:
Publication - ([ a-zA-Z.]+), (\\"[^\\"]+\\") ([^\"]+) and replaced it with: Code:
<h4><ul><li>\2<br/><small>- \1<br/></small>\3</li></ul></h4> |
| Sponsored Links | ||
|
![]() |
| Tags |
| format, regex, regular expression, string, text |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regex date format help | drew211 | UNIX for Dummies Questions & Answers | 3 | 12-12-2011 01:31 AM |
| Help identify string using sed | bobroberts369 | Shell Programming and Scripting | 6 | 10-06-2011 11:31 AM |
| filtering out duplicate substrings, regex string from a string | kchinnam | Shell Programming and Scripting | 8 | 06-15-2010 05:14 PM |
| Help me to identify whats wrong with below script | Just a string to string compare. | KuldeepSinghTCS | Shell Programming and Scripting | 4 | 05-24-2010 03:12 AM |
| Gathering data from complex/large dataspreads .txt format | p43hd | UNIX for Dummies Questions & Answers | 4 | 05-18-2010 03:34 PM |
|
|