To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 139
138  |  140
Subject: 
regular expressions for DAT file subpart lines
Newsgroups: 
lugnet.off-topic.geek
Date: 
Tue, 22 Jun 1999 22:23:19 GMT
Reply-To: 
jsproat@geocities^saynotospam^.com
Viewed: 
152 times
  
Hey Perl fans,

What's your favorite regular expression for a subpart line (or any other
line, for that matter) in an LDraw DAT file?

Here's my entry; $linein is a single line from the DAT file, may or may not
be padded with whitespace at the beginning or the end:

if( $linein =~ m/
  ^
  \s*1             # indicates a subpart
  \s+([0-9]+)      # color
  (?:\s+[0-9]+){3} # coordinates
  (?:\s+[0-9]+){9} # 3 x 3 transform matrix
  \s+(\S+)         # part name
  \s*$
/x ) {
  # $1 = color
  # $2 = subpart name
  # etc...
}

Cheers,
- jsproat

--
Jeremy H. Sproat <jsproat@geocities.com>
http://www.geocities.com/SiliconValley/Horizon/5249/
When constabulary duty's to be done, a Jedi Knight's lot is not a happy one



Message has 1 Reply:
  Re: regular expressions for DAT file subpart lines
 
(...) Whoops! I need to account for floating point values within the matrix. m/ ^ \s*1 # indicates a subpart \s+([0-9]+) # color (?:\s+[+-]?[0-9]+(?:...-9]+)?){3} # coordinates (?:\s+[+-]?[0-9]+(?:...-9]+)?){9} # 3 x 3 transform matrix \s+(\S+) # (...) (25 years ago, 22-Jun-99, to lugnet.off-topic.geek)

9 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR