Discussion:
a regex query
Ron Catterall
2008-01-11 15:09:13 UTC
Permalink
Could this possibly be done by a regex in BBedit? Any
help/suggestions very welcome. (I could do it in PERL of course)

I have some large files that looks like:

<book>
<title>abc</title>
<chapter><title>def</title>
<formalpara><title>.</title> this title is always a single period
<para>ghi</para></formalpara> this text may spread over more lines
<formalpara><title>.</title>
<para>jkl</para></formalpara>
<formalpara><title>.</title>
<para>mno</para></formalpara>
<formalpara ...etc... variable up to about 50 <formalpara>s
</chapter>
<chapter><title>pqr</title>
<formalpara><title>.</title>
<para>stu</para></formalpara>
<formalpara><title>.</title>
<para>vwx</para></formalpara>
<formalpara><title>.</title>
<para>yzz</para></formalpara>
<formalpara ...etc...
</chapter>
<chapter ...etc... variable up to about 30 <chapters>s
</book>
<book>
<title>abc</title>
<chapter><title>def</title>
<formalpara><title>.</title>
<para>ghi</para></formalpara>
<formalpara><title>.</title>
<para>jkl</para></formalpara>
<formalpara><title>.</title>
<para>mno</para></formalpara>
<formalpara ...etc...
</chapter>
<chapter><title>pqr</title>
<formalpara><title>.</title>
<para>pqr</para></formalpara>
<formalpara><title>.</title>
<para>stu</para></formalpara>
<formalpara><title>.</title>
<para>vwx</para></formalpara>
<formalpara ...etc...
</chapter>
<chapter etc
</book>
<book ...etc...

I want to number the <formalpara>s sequentially starting at 1 for
each chapter of each book, i.e.
<book>
<title>abc</title>
<chapter><title>def</title>
<formalpara><title>1.</title>
<para>ghi</para></formalpara>
<formalpara><title>2.</title>
<para>jkl</para></formalpara>
<formalpara><title>3.</title>
<para ...etc...
</chapter>
<chapter><title>pqr</title>
<formalpara><title>1.</title>
<para>mno</para></formalpara>
<formalpara><title>2.</title>
<para>pqr</para></formalpara>
<formalpara><title>3.</title>
<para ...etc...
</chapter>
</book>
<book>
<title>stu</title>
<chapter><title>vwx</title>
<formalpara><title>1.</title>
<para>yzz</para></formalpara>
<formalpara><title>2.</title>
<para>abc</para></formalpara>
<formalpara><title>3.</title>
<para ...etc...
</chapter>
<chapter ...etc...
--
Ron Catterall, Phd, DSc email:
***@catterall.net
Prolongacion de Hidalgo 140 http://catterall.net/
San Felipe del Agua tel: +52 951 520 1821
Oaxaca 68020 Mexico fax: +1 530 348 8309
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Ronald J Kimball
2008-01-11 15:52:25 UTC
Permalink
Post by Ron Catterall
Could this possibly be done by a regex in BBedit? Any
help/suggestions very welcome. (I could do it in PERL of course)
Nope, you can't do this with a regex. There isn't a way to keep track of
the count of <formalpara>s to substitute in. You could write a Perl filter
that you could execute within BBEdit, however.

Ronald
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Ron Catterall
2008-01-11 15:58:21 UTC
Permalink
Many thanks
Post by Ronald J Kimball
Post by Ron Catterall
Could this possibly be done by a regex in BBedit? Any
help/suggestions very welcome. (I could do it in PERL of course)
Nope, you can't do this with a regex. There isn't a way to keep track of
the count of <formalpara>s to substitute in. You could write a Perl filter
that you could execute within BBEdit, however.
Ronald
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
--
Ron Catterall, Phd, DSc email: ***@catterall.net
Prolongacion de Hidalgo 140 http://catterall.net/
San Felipe del Agua tel: +52 951 520 1821
Oaxaca 68020 Mexico fax: +1 530 348 8309
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Jonathan Schwartz
2008-01-11 19:11:01 UTC
Permalink
Hi Folks,

I know how to Open a hidden file.

How do you save a new file to a hidden folder?

For reference, the hidden folder is /usr/local/php5/lib/php

Thanks

J
--
Jonathan Schwartz
Exit 445 Group
***@exit445.com
http://www.exit445.com
415-381-1852
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Maarten Sneep
2008-01-11 19:22:20 UTC
Permalink
Post by Jonathan Schwartz
Hi Folks,
I know how to Open a hidden file.
How do you save a new file to a hidden folder?
For reference, the hidden folder is /usr/local/php5/lib/php
In the save dialog hit cmd-shift-G and type the folder path. Works in
every application on Mac OS X.

Maarten
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Rod Buchanan
2008-01-12 15:54:28 UTC
Permalink
Post by Maarten Sneep
In the save dialog hit cmd-shift-G and type the folder path. Works
in every application on Mac OS X.
Save (and open) dialogs also support tab completion, which is really
cool.

--
Rod

"The Klingon gods were slain by ancient Klingon warriors millennia
ago. They proved more trouble than they were worth."
-- Lt. Commander Worf
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Errol Sayre
2008-01-11 19:26:41 UTC
Permalink
I generally use the "go to folder" option.

When the BBEdit save panel opens, hit shift+command+g and down will
come the go to folder sheet. Then just type in your folder you need to
get to.


You could also open the folder using Terminal "open /usr/local/php5/
lib/php" or use a BBEdit disk browser set to show all files (navigate
to your internal hard drive and you'll see the hidden folders).
Post by Jonathan Schwartz
Hi Folks,
I know how to Open a hidden file.
How do you save a new file to a hidden folder?
For reference, the hidden folder is /usr/local/php5/lib/php
Thanks
J
--
Jonathan Schwartz
Exit 445 Group
http://www.exit445.com
415-381-1852
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Doug McNutt
2008-01-11 19:31:05 UTC
Permalink
Post by Jonathan Schwartz
How do you save a new file to a hidden folder?
For reference, the hidden folder is /usr/local/php5/lib/php
Get thee into BBEdit worksheets.

bbedit /usr/local/php5/lib/php/somethingnew
cp somethingeold /usr/local/php5/lib/php/

Both work fine and they keep you out of the terrible mess that OS neXt has made out of STDFILE.

And. . you can keep the commands in the worksheet for re-execution later with a select and ENTER. (Actually its a select and right click but that's just my mouse preference.)

man bbedit
--
--> From the U S of A, the only socialist country that refuses to admit it. <--
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Errol Sayre
2008-01-11 19:39:27 UTC
Permalink
Post by Doug McNutt
Post by Jonathan Schwartz
How do you save a new file to a hidden folder?
For reference, the hidden folder is /usr/local/php5/lib/php
Get thee into BBEdit worksheets.
bbedit /usr/local/php5/lib/php/somethingnew
cp somethingeold /usr/local/php5/lib/php/
Both work fine and they keep you out of the terrible mess that OS
neXt has made out of STDFILE.
And. . you can keep the commands in the worksheet for re-execution
later with a select and ENTER. (Actually its a select and right
click but that's just my mouse preference.)
Worksheets are kinda wonky... pseudo CLI within a file :-)

Do you use worksheets for all your work? Or is there some hidden way
to convert a normal text file into a worksheet?

Could you give some examples of why worksheets are more valuable than
a text file?

"ls -laG >> myfile.txt" works just as well as "ls -laG" within a
worksheet from my experience —especially since BBEdit updates open
documents when it activates, though generally cutting and pasting
works best for me.
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Errol Sayre
2008-01-11 19:55:43 UTC
Permalink
My apologies for hitting reply... and not starting a new thread.
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Doug McNutt
2008-01-11 21:29:55 UTC
Permalink
Post by Errol Sayre
Worksheets are kinda wonky... pseudo CLI within a file :-)
Yep. But you should use them.

As of BBEdit 7 or so they are plist files as opposed to ordinary text files and that change frustrates me because they're now impossible to interchange with MPW (Macintosh Programmer's Workshop - from Apple) files on this 8500 running OS 9.1.

I can no longer write a short tool in C and include the compiler commands between comments

#ifdef nonsense
cc this file
link *.o
exit
#endif

so I could execute the source file to compile and link it.
Post by Errol Sayre
Do you use worksheets for all your work? Or is there some hidden way to convert a normal text file into a worksheet?
I use worksheets as a replacement for Finder and I have done so since OS 5 or so on a Mac-II. Login always starts up a worksheet which retains a record of where I have been and what I have been doing. I can "open -a Vectorworks someCADstuff" and be right back where I was.

Converting between worksheets and text files is a PITA now that worksheets are different. The simplest way is to make a new text or worksheet and copy-paste the text you want. Just changing the HFS file type works not. And you can't put #!/usr/bin/perl at the top of a worksheet and execute it though you once could.
Post by Errol Sayre
Could you give some examples of why worksheets are more valuable than a text file?
You can select and ENTER to execute commands in the shell of your choice. Output from the command is placed right after the command line(s) you executed. With a text file you're reduced to copy and paste into Terminal.app.
Post by Errol Sayre
"ls -laG >> myfile.txt" works just as well as "ls -laG" within a worksheet from my experience -especially since BBEdit updates open documents when it activates, though generally cutting and pasting works best for me.
ls -laG | bbedit mynewfile.txt # is another option that will create and open a new document

But you have to type, or copy-paste - that into terminal. With a worksheet you just select the existing line and ENTER. Using the mark menu allows you to flag areas of the worksheet so you can get there easily but you can't alphabetize the marks the way MPW does it.

Yes I miss the ability to redirect output into the current selection in an open file that was possible in MPW. You can only redirect to the end of an existing file and that will show up at the end if its open in BBEdit but you better be careful with saving the target file before you do it.

I never used BBEdit until worksheets became available and now that MPW is unsupported by Apple and will never be ported to OS neXt I have become a BBEdit fan though I do tend to use MPW and OS 9 on this 8500 for real text-based operations. There I have Nisus I can use for playing with tab separated data with divers column widths and mixed line ends that need to stay that way.

The worksheet I use for web site maintenance has a bunch of scp commands using ssh. I have a certificate set up on the server and I can define shell variables that make moving files around pretty simple, documented, and reproducible just because the worksheet retains all of the commands. I like it better than BBEdit's ftp capabilities. You can also pipe ssh command output to the bbedit tool so that you get a local file to look at.

My worksheets have AppleScripts buried in them awaiting execution. zB

osascript << ENDSCRIPT
Tell front window of application "Finder" to update every file
ENDSCRIPT

In short, BBEdit worksheets are a great interface between the OS neXt CLI and its GUI. Better than Finder if you know what you're doing. My only wish is that Bare Bones would take MPW compatibility a whole lot further. gedit is something I have been looking at and, with open source code, I can add MPW-like things myself. dash - a flavor of bash - looks as though it will process commands using a piped interface. I have been trying, without success, to use a BBEdit worksheet on OS neXt and deliver its CLI commands for execution on a Linux machine.

Do try worksheets. I have waxed too cynical about my pet peeves.
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Dennis
2008-01-11 22:56:59 UTC
Permalink
Post by Doug McNutt
You can select and ENTER to execute commands in the shell of your
choice. Output from the command is placed right after the command
line(s) you executed. With a text file you're reduced to copy and
paste into Terminal.app.
Unless you write a simple AppleScript to execute a selection in a
BBEdit text document using "do shell script" and insert the result
after the original selection. :)

I have my script set to use the entire current line if nothing is
selected. It also uses the appropriate interpreter (php -r, perl -e,
ruby -e, etc.) based on the source language of the document. It's
great for quickly testing a portion of code while working on a larger
project.

-Dennis
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Doug McNutt
2008-01-12 00:01:37 UTC
Permalink
You can select and ENTER to execute commands in the shell of your choice. Output from the command is placed right after the command line(s) you executed. With a text file you're reduced to copy and paste into Terminal.app.
Unless you write a simple AppleScript to execute a selection in a BBEdit text document using "do shell script" and insert the result after the original selection. :)
I have my script set to use the entire current line if nothing is selected. It also uses the appropriate interpreter (php -r, perl -e, ruby -e, etc.) based on the source language of the document. It's great for quickly testing a portion of code while working on a larger project.
Is your script posted somewhere?

I have tried that kind of thing but do shell script always starts a new environment and anything you have defined as a shell variable disappears. Setting up a Terminal.app window and making the Applescript run tell application "Terminal" to do script "fill it in" in window "named" allows you to set things up in advance.

The directory:
<ftp://ftp.macnauchtan.com/Software/BBEdit/> contains
<ftp://ftp.macnauchtan.com/Software/BBEdit/WorksheetOpen_ReadMe>
<ftp://ftp.macnauchtan.com/Software/BBEdit/WorksheetOpen>
<ftp://ftp.macnauchtan.com/Software/BBEdit/WorksheetShopen>

which I use to automatically open and set up environment variables when I open a worksheet.

<ftp://ftp.macnauchtan.com/Software/Progress/tViewInit>
<ftp://ftp.macnauchtan.com/Software/Progress/tView.text>

Is some drivel I prepared to open a named Terminal.app window for the purpose.

BareBones has done a lot with the #! menu item that ought to make simple text files more amenable to embedded shell commands but I haven't figured it all out. Part of it is that I'm stuck at version 8.5.2 because I simply have to be able to continue using my SE/30, OS 7.5, file server with OS 10.3.9. That box can still talk to my oscilloscope using RS232 and a.out.

There is also an "execute text" service that I found somewhere. It is essentially a do shell script in a new shell instance.

gedit has an easy to use procedure for running shell commands and you can pass output from a command to the current insertion point. It's actually close to being a workable development environment for simple things that don't justify Eclipse or cvs. But. . . It isn't nearly the friendly editor that BBEdit is.
--
--> From the U S of A, the only socialist country that refuses to admit it. <--
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Dennis
2008-03-21 00:12:24 UTC
Permalink
Post by Doug McNutt
Post by Dennis
Unless you write a simple AppleScript to execute a selection in a
BBEdit text document using "do shell script" and insert the result
after the original selection. :)
I have my script set to use the entire current line if nothing is
selected. It also uses the appropriate interpreter (php -r, perl -
e, ruby -e, etc.) based on the source language of the document.
It's great for quickly testing a portion of code while working on a
larger project.
Is your script posted somewhere?
I sincerely apologize for not responding to this *months* ago. But
better late than never...

Here's a link to my "Run Shell Command" BBEdit script, which simply
executes the selection or current line as a shell command and returns
the output on the line below. You can also find a couple other of my
favorites (Toggle Quotes, Join Line with Next, Calculate):

http://homepage.mac.com/dennisrande/FileSharing41.html

Feedback, improvements, and fixes gladly accepted!

-Dennis
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Lewis@Gmail
2008-01-13 17:20:35 UTC
Permalink
Post by Errol Sayre
"ls -laG >> myfile.txt" works just as well as "ls -laG"
I usually do something like

% ls -laG | bbedit

--
This is our music from the bachelor's den, the sound of loneliness
turned up to ten. A harsh soundtrack from a stagnant waterbed and it
sounds just like this. This is the sound of someone losing the plot,
making out that they're OK when they're not. You're gonna like it,
but not a lot. And the chorus goes like this...
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Errol Sayre
2008-01-13 19:08:20 UTC
Permalink
Post by ***@Gmail
Post by Errol Sayre
"ls -laG >> myfile.txt" works just as well as "ls -laG"
I usually do something like
% ls -laG | bbedit
Well, BBEdit has the "Verify open files" option which makes it really
easy to append content to a file that you're already editing within
BBEdit. Once you come back from the Terminal, BBEdit reloads the
contents of the file and finds the new content...
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Terry Ofner
2008-01-12 15:54:12 UTC
Permalink
This is my first post on this list, so forgive me if this topic has
already been addressed.

I love the html palette. I am wondering, however, if there is a way
to add my own xml tags to it. Say I need to mark up a document using
tags not available on the html palette:

<state-standard>1.3 standard text here.</state-standard>

It would be wonderful to be able to highlight the text and hit a
button on the palette to add the markup.

Any suggestions?

Terry Ofner
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Jack Hodgson
2008-01-12 17:08:17 UTC
Permalink
Clippings!

I use them all the time.

eg: <state-standard>#SELECT#</state-standard>

-- Jack Hodgson
Post by Terry Ofner
This is my first post on this list, so forgive me if this topic has
already been addressed.
I love the html palette. I am wondering, however, if there is a way
to add my own xml tags to it. Say I need to mark up a document
<state-standard>1.3 standard text here.</state-standard>
It would be wonderful to be able to highlight the text and hit a
button on the palette to add the markup.
Any suggestions?
Terry Ofner
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <***@barebones.com>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <bbedit-talk-***@barebones.com>
Continue reading on narkive:
Loading...