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 January 27th, 2009, 09:00 AM
andydouth andydouth is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 3 andydouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 4 sec
Reputation Power: 0
Select specific field from CSV

Hi,

I am not using regex alongside another language it is infact used in an application I am running and trying to customize. Its basically a firewall log.

I have a csv:

<25>Jan 23 03:52:57 192.168.27.200 20090123, 9380690, 2009/01/23 10:52:54, 2009/01/23 10:52:53, global.devices, 499, mydevice, 0.0.0.0, traffic, traffic log, trust, (NULL), 10.1.2.6, 4021, 216.141.86.226, 1516, untrust, (NULL), 216.34.209.13, 80, 216.34.209.13, 80, tcp, global.devices, 499, Combined-Demo, fw/vpn, 32, accepted, info, no, Close - TCP FIN, (NULL), (NULL), (NULL), 1, 853, 715, 1568, 0, 0, 10, 1, no, 0, Not Set, sos

and I want to extract fields by selecting field 5 which should be global.devices. Field 5 could have anything in here not just english chars and .'s. I would like to use this construction to eventually pick any field I want out of the csv, not just 5.

Any help here greatly appreciated - I have tried allsorts but to no avail.

Reply With Quote
  #2  
Old January 27th, 2009, 04:52 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,685 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 58 m 7 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
If there are commas in one of the fields (and so it has quotes around it) it'll be more complicated.

When asking for regex help it's always nice to tell us what flavor of regex it is. They're all subtly different. Or in your case, what program you're using.
Code:
^(\s*([^,]*),?){5}

$2 is the field you want, regardless of what number you have in the {}s.

Reply With Quote
  #3  
Old January 27th, 2009, 05:24 PM
andydouth andydouth is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 3 andydouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 4 sec
Reputation Power: 0
Thanks I will try that when I am in the office tomorrow. The program is radar by q1labs and I have no idea what version of regex it is.

Reply With Quote
  #4  
Old January 28th, 2009, 10:48 AM
andydouth andydouth is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 3 andydouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 4 sec
Reputation Power: 0
Quote:
Originally Posted by andydouth
Thanks I will try that when I am in the office tomorrow. The program is radar by q1labs and I have no idea what version of regex it is.


This is so close !

It is selecting the , on the end is there a simple way of removing this?

Thanks

Reply With Quote
  #5  
Old January 28th, 2009, 03:46 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,685 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 2 h 58 m 7 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Hmm, you must be using it a bit differently than I thought.
Code:
^\s*[^,]*(,\s*([^,]*)){4}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Select specific field from CSV

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