On 5 Feb 2009, at 20:48, Lorin Rivers wrote:

>
> I have some data that looks like this:
>
> # visitors
> # 2009-02-04
> Item,Value,Value Percent,URL,Mumble URL
> "",498,,"",""
>
> # 2009-02-03
> Item,Value,Value Percent,URL,Mumble URL
> "",351,,"",""
>
>
> #visitors is the first line of the document
> the other bits continue in sequence
>
> I want it to look like this:
> "visitors","2009-02-04","498"
> "visitors","2009-02-03","351"

I think that for this you might like to try:

Find: # (\d\d\d\d-\d\d-\d\d)\rItem,Value,Value Percent,URL,Mumble URL 
\r"",(\d\d\d),,"",""
Replace: "visitors","\01","\02"

There's a chance the find expression has had a line break inserted by  
the email system.

It is a simple operation. The line breaks in the example are changed  
to \r. The relevant bits are captured by the parenthesis and put into  
the replace expression.

> for bonus points, this data is grouped and after the visitors section,
> there's a section starting with:
> # pages
> followed by repeating structures like this (an integer is really a
> number like 123 and a float is similar 12.3 or the like):
> # 2009-02-04
> Item,Value,Value Percent,URL,Mumble URL
> "a string",an integer,a float,"a url",""
>
> transformed to
> "pages","2009-02-04","a string","a url","an integer","a float"

This is a bit unclear. I think we lost something in the email system.

The solution is very similar to the first example. I think that you  
could put it together yourself.

To identify a digit in the find expression use \d which means  
character class [0-9].

To capture in find expression use parenthesis.

To put those into the replace expression use \01 \02 etc numbering  
from left to right.

All you need to do is create a find expression that matches it all.  
Then capture what you require and reassemble in the replace expression.

BBEdit help has the Grep Reference which is very useful.

No text factories will be required.

Patrick

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to "[email protected]" 
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to