Help with SANDR expression syntax (again)

barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

Help with SANDR expression syntax (again)

Post by barry.marcus »

I have a lot of data that has certain start and end "delimiters" that surround key words. I want to eliminate the delimiters and "replace" them with an indication that this was done after the delimited word. This is easier to explain with an example. If I encounter the following string:

"...the keyword is DELIM=START foobar DELIM=END in this sentence..."

I want to end up with:

"...the keyword is foobar* in this sentence..."

In this case the start and end delimiters are "DELIM=START" and "DELIM=END" and the "indicator" is an asterisk. The sandr should strip those out and put the asterisk after the delimited word, in this case "foobar".

FYI, there will always be just a single word (i.e., a string with no spaces) between the start and end delimiters.

Thanks for the help.
User avatar
John
Site Admin
Posts: 2623
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Help with SANDR expression syntax (again)

Post by John »

If we build the search up in pieces:

>>DELIM\=START= -- The start delimiter
\space+ -- Spaces after the delim
[^\space]+ -- Keyword
\space+ -- Spaces after the keyword
DELIM\=END= -- The end delimiter

So:

>>DELIM\=START=\space+[^\space]+\space+DELIM\=END=

The replace would be \2\3*\4 for the spaces, keyword, indicator and more spaces.
John Turnbull
Thunderstone Software
barry.marcus
Posts: 288
Joined: Thu Nov 16, 2006 1:05 pm

Help with SANDR expression syntax (again)

Post by barry.marcus »

Thanks, John