Rex with # of characters

Post Reply
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Rex with # of characters

Post by source1ben »

How would I use the rex statement to obtain a given number of characters to the left & right of an indicator. For example - here is the string I am evaluating.

Plummeting *[oil]* prices have eroded the value

I want to return a string with 11 characters to the left & 11 characters to the right of data that is enclosed in the *[oil]* brackets. Therefore, my desired output is.

Plummeting *[oil]* prices hav

Here is my unsuccessful effort.

<rex "w/11[^\*\[] W/" $variable>

thx.
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Rex with # of characters

Post by John »

You can give a number of characters as a repetition operator, e.g.

<rex ".{0,11}>>\*\[=[^\]]+\]\*=.{0,11}" $variable>

The {0,11} says 0 to 11 characters, in case there aren't 11 characters before or after the anchor.
John Turnbull
Thunderstone Software
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Rex with # of characters

Post by source1ben »

Works great !! thx.
Post Reply