On Tue, Sep 06, 2011 at 07:50:30AM -0700, jefferis wrote:
> Hi,all. I'm trying to do the research and learn the proper syntax, but
> I keep getting confused by the web page descriptions. Just a little
> background: I am a visual learner. I was great in Geometry but my
> algebra teacher said "Jeff tries very hard but has no natural
> aptitude" :-)  In other words, I can see pictures in my head and
> rotate 3D puzzles, but abstract equations with symbolic language
> become a complete mystery to me.     Rather than pester this group for
> basic questions, can anyone recommend a short site or GOOD, SIMPLE
> book that would show me how?

If you want to learn how regular expressions work and how to use them, I'd
recommend Mastering Regular Expressions, from O'Reilly:
<http://oreilly.com/catalog/9780596528126>

If you just want a syntax reference, they also have a Regular Expression
Pocket Reference: <http://oreilly.com/catalog/9780596514273>

As to visual learning, you might look for a text that explains regular
expressions in terms of finite automata, with diagrams.  I don't remember
if Mastering Regular Expressions includes some of that.


> In the meantime, I'm faced with a complex replacement problem.... I
> would appreciate instruction on it.
> 
> My client wants me to take a tool tip for hundreds of items and wants
> me to add a tab after the item number and then remove numbers at the
> end of the phrase.
> 
> As a sample the numbers and letters up to the first space are the item
> number. Description text is variable in lenght and the last set of
> numbers are to be removed. The codes are only numbers preceded by a
> space.
> 
> 26119BCZZD002CR01 Edward Piguet Tourbillon with Diamond Bezel White
> and lots of gold stuff  73245

We need a little more information to solve this.

First, what is the form of the item numbers?  Do they always start with the
same digits, or have the same pattern of digits and letters?

Second, what is the context of these strings?  Are they attribute values in
HTML pages, or one per line in text files, or something else?

You need to not just match the strings you want, but also not match the
strings you don't want.  That's why we need that additional information.


That said, your search/replace would look something like this:

Find

(\d{5}[A-Z]{5}\d{3}[A-Z]{2}\d{2}) (.*?) +(\d+)

Replace

\1\t\2

Here I've assumed that item numbers are identified by the pattern of
digits and letters.  It matches the item number, a space, the description,
and then one or more spaces followed by a number.  It replaces this with
the item number, a tab, and the description.


Ronald

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to