CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
regular expression

 



moneysab
New User

Sep 24, 2014, 12:35 PM

Post #1 of 3 (32548 views)
regular expression Can't Post

how do i create a regular expression for a nfl players that threw for 3000 or more yards and more than 30 touchdowns.

example:

Name ,team,position,350,541,64.7,33.8,"4434",8.2,277.1,"30",7,197,36.4,83T,55,17,50,103.2

from above i am interested in only 4434 and 30 (one in double "").


BillKSmith
Veteran

Sep 24, 2014, 9:18 PM

Post #2 of 3 (32541 views)
Re: [moneysab] regular expression [In reply to] Can't Post

I doubt that you can. Even if you can, it would be a bad solution to your problem because it is far beyond what regular expressions are intended to do. A range of numeric values is not a 'pattern'.

You have a .csv file. You first have to parse it into columns. Based on your single sample, you could split the line on commas. A better solution is to use a module such as Text::CSV.
Good Luck,
Bill


Laurent_R
Veteran / Moderator

Sep 24, 2014, 11:22 PM

Post #3 of 3 (32539 views)
Re: [moneysab] regular expression [In reply to] Can't Post

You probably can do it with a regex, but it would be a very very bad idea.
Use a module such as Text::CSV or use split:

Code
my ($distance, $touchdowns) = (split /,/, $string) [7, 10];


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives