REX Expression

Post Reply
kzinda
Posts: 62
Joined: Fri Nov 30, 2001 6:18 am

REX Expression

Post by kzinda »

If I had two phrases in my document such as "...10,000 cycles of life ..." and "...4.0 life test cycles ..." that I wanted to identify, would I write my REX expression as:

cycle life w/20\digit+
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

REX Expression

Post by John »

I think the query you want is:

cycle life /\digit+ w/20

which looks for "cycle" "life" and a number within 20 characters.
John Turnbull
Thunderstone Software
kzinda
Posts: 62
Joined: Fri Nov 30, 2001 6:18 am

REX Expression

Post by kzinda »

I've tried a similar approach to find number strings such as: 10.sup.-12 units without success. I used the REX expression:

units /[0-9]+\.sup.\[+\-]?[0-9]? w/24

I also tried

units /[0-9]+\.sup.[+\-]?[0-9]? w/24

Both failed. Texis seemed to have problems resolving the [+/-] term.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

REX Expression

Post by mark »

You forgot the = after .sup.
/[0-9]+\.sup\.=[+\-]?[0-9]+ w/24

When in doubt test with rex on the command line.
rex -x '[0-9]+\.sup\.=[+\-]?[0-9]+'
will show you how it parsed the expression.
echo '10.sup.-12'|rex -p -P '[0-9]+\.sup\.=[+\-]?[0-9]+'
will show you what, if anything, matches.

Also, the w/ operator if fairly irrelevant if your query only has one term as in this case.
kzinda
Posts: 62
Joined: Fri Nov 30, 2001 6:18 am

REX Expression

Post by kzinda »

I do not fully understand why the "=" needs to be added here. Could you explain its use and interpretation here.

And how do I force REX to only accept those hits where the number preceeds the word I am looking for, such as "units" in this example?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

REX Expression

Post by mark »

= means exactly one of the previous subexpression. ie {1,1}
Without it you're saying, in this case, 0 or 1 of .sup.[+-]

[0-9]+\.sup\.=[+\-]?[0-9]+ units
Post Reply