a regular expression question, or at least a text manipulation question

Jim Ault JimAultWins at yahoo.com
Wed Aug 27 17:22:04 EDT 2008


I may be solving the wrong problem for you but see if this works

The prefix will always be word 1 of each line
You do not need case-sensitive
the delimiter is a tab

------------- start copy
on test
  put the clipboarddata into incomingList
  filter incomingList without empty
  repeat for each line LNN in incomingList
    put word 1 of LNN & cr after prefixList
  end repeat
  
  split prefixList using cr and tab
  put the keys of prefixList into prefixList
  set the itemdel to tab
  
  repeat for each line LNN in prefixList
    get incomingList
    filter it with LNN & "*"
    replace cr with tab in it
    put it & cr after packedList
  end repeat
  
  put packedList into msg
  
end test

------ end copy

Jim Ault
Las Vegas



On 8/27/08 1:35 PM, "Peter Alcibiades" <palcibiades-first at yahoo.co.uk>
wrote:

> How do you do the following?
> 
> I have a series of lines which go like this
> 
> |  [record separator, new record starts]
> AAA consectetur adipisicing elit, sed
> BBB lorem ipsum
> CCC consectetur adipisicing elit, sed
> CCC laboris nisi ut aliquip ex ea
> DDD ut aliquip ex ea commodo
> | [record separator]
> AAA adipisicing elit, sed   [new record starts]
> 
> | is the record separator.
> 
> In the above, its CCC that is repeated, but it could be any prefix.  Also CCC
> is next to its repetition.  This will always be the case.
> 
> I want to go through the file.  When I find a single prefix (like AAA) this
> should be written to the output file.  when the next line starts with the
> same prefix (as in the CCC cases, I want to put both occurences on the same
> line.  So the desired output would be
> 
> AAA consectetur adipisicing elit, sed
> BBB lorem ipsum
> CCC consectetur adipisicing elit, sed CCC laboris nisi ut aliquip ex ea
> DDD ut aliquip ex ea commodo
> EOR
> AAA adipisicing elit, sed
> 
> How do I detect a repetition of that sort and do this?
> 
> A similar question, if the line is
> 
> CCC  adipisicing elit, sed TAB CCC  adipisicing elit, sed
> 
> How do you detect the multiple occurence (I can do this with regex) and then
> write out in place of thie above expression (this I don't see how to do) the
> following:
> 
> CCC  adipisicing elit, sed CCC  adipisicing elit, sed
> 
> Obviously, the pseudo latin is different in each case, so no way to check
> using that.
> 
> Peter
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list