The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract string between <> rakeshou Shell Programming and Scripting 14 11-21-2007 01:10 PM
How to Extract string? namrata5 High Level Programming 2 10-24-2007 04:17 AM
Extract digits at end of string offirc Shell Programming and Scripting 6 11-20-2006 11:57 AM
Extract String bestbuyernc Shell Programming and Scripting 5 11-14-2005 03:42 PM
How to extract a portion of a string from the whole string ds_sastry UNIX for Dummies Questions & Answers 2 09-29-2001 11:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-25-2006
sehgalniraj sehgalniraj is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 11
Extract String

I wanted to extract -151557 and 6768743 from the below line. Don't know how can i do using regular expression.

These are mX and mY coordinates for a particular geographic location.
So any coordinate like number after string 'mX' will be mX
any coordinate like number after string 'mY' will be mY

which i want to extract





Code:
<div align="center"><center><table border="1" cellspacing="1" width="70%"><tr> <td width="50%" align="center" valign="middle"><strong>OS X</strong> </td> <td width="50%" align="center" valign="middle">443921 </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>OS Y</strong> </td> <td width="50%" align="center" valign="middle">235124 </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>Post Code</strong>
 </td> <td width="50%" align="center" valign="middle">OX15 4HE </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>Lat</strong> (WGS84)  </td> <td width="50%" align="center" valign="middle">N52:00:46 ( 52.012814 ) </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>Long</strong> (WGS84)  </td> <td width="50%" align="center" valign="middle">W1:21:41 ( -1.361467 ) </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>LR</strong> </td>
 <td width="50%" align="center" valign="middle">SP439351 </td></tr><tr> <td width="50%" align="center" valign="middle"><strong>mX</strong> </td> <td width="50%" align="center" valign="middle">-151557</td></tr><tr> <td width="50%" align="center" valign="middle"><strong>mY</strong> </td> <td width="50%" align="center" valign="middle">6768743 </td></tr><tr> <td width="50%" align="center" valign="middle">
<strong>M</strong> </td> <td width="50%" align="center" valign="middle">Actual : FFFDAFFB_00674867<br>Street : FFFDB034_00674774<br>Road   : FFFDB610_00672640<br>Road64 : FFFE0C00_00668A00<br>Road128: FFFE0C00_00659000</td>
</tr><tr> <td width="100%" align="center" valign="middle" colspan="2" ><strong><a href="http://www.streetmap.co.uk/streetmap.dll?grid2map?X=443921&Y=235124&arrow=Y&adkey="~"">Click here to see location</a> </strong>



Any suggestion pls

Last edited by vino; 09-25-2006 at 12:17 PM.. Reason: Added code tags
  #2 (permalink)  
Old 09-25-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
Try this:

Code:
$ sed 's/\<[^<]*\>//g;s/.*mX *\([-0-9]*\).*$/\1/' < string
-151557
$ sed 's/\<[^<]*\>//g;s/.*mY *\([-0-9]*\).*$/\1/' < string
6768743
$

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0