Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2012, 04:25 AM
like_ipodvn like_ipodvn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 1 like_ipodvn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 24 sec
Reputation Power: 0
Get name and address

Hi all,

I have text file format as :
Name: Suzanne D. Scott, M.D.
Class: 66007
Birthday: 6/1988
Regcode: 6221
Description: lobotango
Phone: 910-767-9881
Address: 2995 Crown Piece Drive
San Antonio, Texas, 240 United States

---

Name: Perter D. Jonh, Msc
Class: 37007
Birthday: 12/1977
Regcode: 6221
Description: lobotango
Phone: 172-364-9432
Address: 6688 King Drive
Dreame, California, 240 United States


---


Name: Perter D. Jonh, Msc
Class: 37007
Birthday: 12/1977
Regcode: 6221
Description: lobotango
Phone: 172-364-9432
Address: 6688 King Drive
Dreame, California, 240 United States


---

How can i use Regex to get name and address !
Address in above file are 2 lines in file.

Have you any ideas ?

Thank you very much !

Reply With Quote
  #2  
Old February 13th, 2012, 07:35 AM
ragax's Avatar
ragax ragax is offline
Turn left at the third duck
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Location: Nelson, NZ
Posts: 93 ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level)ragax User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 24 m 37 sec
Reputation Power: 92
Hi there,

Depending on your language, some kind of "match all function" with the following regex will give you the names and addresses.

Code:
(?s)Name:([^\r\n]+)[\r\n]+.*?Address:([^\r\n]+[\r\n]+[^\r\n]+)


The names are in Group 1, the addresses are in Group 2.
For instance in php you can use a preg_match_all.

Going to bed now but if you have any question someone else will be able to give you more detail.
__________________
Regex Tutorial | Latest RegexBuddy Demo

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Get name and address

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap