Find the 1ST OCCURRENCE of a word in parentheses, ignore oth
Posted: Fri Jun 20, 2003 5:05 pm
Spreadsheet-like, I am assembing my tab-delimited database. Here is a crude layout of part of it:
^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(456)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(789)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
"Rndm" means really that these are random (unique) words/strings, and thus I have nothing consistent to link to.
But the columns are fixed; and the parenthetical items — which will always appear at these fixed tab positions — stand for 3 specific telephone area codes: I've labeled them (123), (456) and (789) in this example; note the presence of two area codes on each line/record.
It's the first occurence of an area code on each line that I wish to operate on, and here is what I'm hoping to quickly do:
Find the first area code on each line
Mark those lines
On the marked lines, insert a two-letter code unique to that particular area code right after the 1stRndmWORD+TAB on that line.
EXAMPLE WHEN FINISHED:
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……PK……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(456)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……RW……(789)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
The conflict I'm having relates to the lines that have two different area codes on the same line.
For example, when I'm looking for (123)+TAB, the line
^1stRndmWORD+TAB……RndmWORD+TAB……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
finds the (123)+TAB also, when I wouldn't want that record marked because its lead area code is (456)+TAB.
(456)+TAB is also taking (456)+TAB
(789)+TAB is also taking (789)+TAB
and so on. I know I'm not great at being clear with these examples, so please feel free to discipline my thinking. I just need to end up with these three 2-letter codes — QL, PK, and RW — on their lead area codes.
Thanks guys!
Skye

^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(456)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……(789)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
"Rndm" means really that these are random (unique) words/strings, and thus I have nothing consistent to link to.
But the columns are fixed; and the parenthetical items — which will always appear at these fixed tab positions — stand for 3 specific telephone area codes: I've labeled them (123), (456) and (789) in this example; note the presence of two area codes on each line/record.
It's the first occurence of an area code on each line that I wish to operate on, and here is what I'm hoping to quickly do:
Find the first area code on each line
Mark those lines
On the marked lines, insert a two-letter code unique to that particular area code right after the 1stRndmWORD+TAB on that line.
EXAMPLE WHEN FINISHED:
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……PK……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(456)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……QL……(123)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
^1stRndmWORD+TAB……RndmWORD+TAB……RW……(789)+TAB……RndmWORD+TAB……RndmWORD+TAB……(789)+TAB……etc.
The conflict I'm having relates to the lines that have two different area codes on the same line.
For example, when I'm looking for (123)+TAB, the line
^1stRndmWORD+TAB……RndmWORD+TAB……(456)+TAB……RndmWORD+TAB……RndmWORD+TAB……(123)+TAB……etc.
finds the (123)+TAB also, when I wouldn't want that record marked because its lead area code is (456)+TAB.
(456)+TAB is also taking (456)+TAB
(789)+TAB is also taking (789)+TAB
and so on. I know I'm not great at being clear with these examples, so please feel free to discipline my thinking. I just need to end up with these three 2-letter codes — QL, PK, and RW — on their lead area codes.
Thanks guys!
Skye
