Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex not working - "IN.*" 1

Status
Not open for further replies.

Imagineer

New member
Mar 28, 2000
43
US
Hmm.. for some reason this regex is not working. I am using the cygwin version of gawk.

It only finds lines 1, 2, 13, 18, 31, 38 of the attached file. It appears that the "*" is not working. I really wanted it to match lines 21, 25, 31, 50. I even tried "IN..", still no luck.

TIA,
Imagineer

command line: grep "IN.* " easynum.txt
Note I am using this in an AWK script but using grep to do a little debugging.

Easynum.txt:
1 *TITLE 'EXFR01 - EXAMPLE OF GTSTRUDL MOVING LOAD GENERATOR'
2 STRUDL 'EXFR01' 'EXAMPLE OF GTSTRUDL MOVING LOAD GENERATOR'


3 $
4 $***********************************************************************
5 $* ** PROBLEM DESCRIPTION: Sample problem for Frame Analysis. This
6 $* ** is an example problem of the Moving Load
7 $* ** Generator from Section 2.1.11.3.5.8,
8 $* ** Volume 1, of the GTSTRUDL User's Manual.
9 $***********************************************************************
10 $


11 UNITS KIPS FEET
12 TYPE PLANE FRAME
13 JOINT COORDINATES
14 1 0.0 0.0 S
15 2 80.0 0.0 S
16 3 180.0 0.0 S
17 4 240.0 0.0 S
18 JOINT RELEASES
19 1 TO 4 MOMENT Z
20 1 TO 3 FORCE X
21 MEMBER INCIDENCES
22 1 1 2
23 2 2 3
24 3 3 4
25 UNITS INCHES
26 MEMBER PROPERTIES
27 1 TO 3 AX 20. IZ 300.
28 CONSTANTS
29 E 29000. ALL
30 $
31 $ THE FOLLOWING DESIGN FACTORS WILL BE INCLUDED:
32 $ NUMBER OF LANES = 2
33 $ IMPACT FACTOR = 1.25
34 $ ECCENTRICITY FACTOR = 1.1
35 $ TOTAL FACTOR (2 x 1.25 x 1.1) = 2.75
36 $
37 UNITS FEET
38 MOVING LOAD GENERATOR
39 SUPERSTRUCTURE NUMBER OF SECTIONS 8 MEMBER 1 NUMBER OF SECTIONS 10 -
40 MEMBER 2 NUMBER OF SECTIONS 6 MEMBER 3
41 TRUCK LOAD FORWARD HS20-44
42 LANE LOAD P 18. AND W 0.64 ALL
43 GENERATE LOAD Y SCALE -2.75
44 END LOAD GENERATOR
45 $
46 STIFFNESS
47 $
48 LIST FORCE ENVELOPE MEMBER 1 2 3 SECTION FRAC DS 0.0 0.1
49 $
50 FINISH



Imagineer
 
Oops, there should be a space after the *. The regex tried is "IN.* ". Basically, I'm trying to find words beginning with "IN".

Thanks again,
Imagineer
 
Hi Imagineer,

It could be the space after the *

Hope this helps. CaKiwi
 
But I need the space to define end-of-word. Otherwise the expression would match to end-of-line. Since I will be holding the word, I don't want the rest of the line.

Imagineer
 
Maybe
Code:
"IN[^ ]*"
will do it. If not, put a space on the end of every line before processing it. CaKiwi
 
hmm... why the ^? Isn't that the beginning-of-line metachar? Do you mean the negation operator "!"?

Thanks,
Imagineer
 
Nevermind. I found the note that the circumflex is the negation operator if it is the first character in []. Imagineer
 
With gawk :

awk '/\<IN/' easynum.txt
Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top