Re: Grep two things at once?

This WebDNA talk-list message is from

2005


It keeps the original formatting.
numero = 63073
interpreted = N
texte = Since you may be looking at getting started in this area, I can offer some suggestions and tips. There are at least two grep specific issue in WebDNA (as opposed to the general issues of URLing values to get them by the parser). They are these: Issue 1: There is no way to operate a match for one or more using the "+" sign. That is pretty much standard grep syntax. And one or more is significant. There are times where zero or more is not precise. The workaround is to specify your pattern twice and follow the second pattern with zero or more, i.e. "*". This has the identical effect to one or more at the expense of code bloat. Issue 2: This is a conceptual difference. Grep is actually a bit of a misnomer for the command. I think REGEX editor is more accurate. Here's why: First grep typically operates line by line returning the entire line (or filename) that matches (this supposedly can be worked around but is not the default). WebDNA will not break at the line end by default. To me this difference is neither good nor bad. Second, grep does not replace anything. It only matches. To make changes, one must edit. At the command line, this is done by tools other than grep. Sed in particular comes to mind. This to me is problematic as a concept. Do not expect grep at the command line to provide a search and replace. Also, if you are learning regex, there are two nice places to experiment. The command line is nice since it is a good way to review multiple files. Try grep and sed for starters. The other place is BBEdit if you have a Mac. It has a nice regex search tool. The power of learning regex is that you can use just about in any programming or web related tool: perl, js, apache (modrewrite in particular), webdna, php, SQL. Bill -----Original Message----- From: Dan Strong Sent: Wed, 21 Sep 2005 10:47:28 -0700 To: "WebDNA Talk" Subject: Re: Grep two things at once? John, thank you. So far I've been able to get away with simple grep stuff, but I guess it's time to get the book ... :) -Dan On Wed, 21 Sep 2005 13:38:59 -0400 John Peacock wrote: > Dan Strong wrote: >> Example: I want to search for any dashes and a spaces in some text and >> replace them with underscores. > > Get the O'Reilly book "Regular Expressions" if you want to do anything significantly useful with >[grep]. This will do what you want: > > [grep search=[- ]&replace=_]the text[/grep] > > The [- ] signifies a set of characters. > > HTH > > John > > -- > John Peacock > Director of Information Research and Technology > Rowman & Littlefield Publishing Group > 4501 Forbes Boulevard > Suite H > Lanham, MD 20706 > 301-459-3366 x.5010 > fax 301-429-5748 > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Grep two things at once? ( devaulw@onebox.com 2005)
  2. Re: Grep two things at once? ( "Dan Strong" 2005)
  3. Re: Grep two things at once? ( John Peacock 2005)
  4. Grep two things at once? ( "Dan Strong" 2005)
Since you may be looking at getting started in this area, I can offer some suggestions and tips. There are at least two grep specific issue in WebDNA (as opposed to the general issues of URLing values to get them by the parser). They are these: Issue 1: There is no way to operate a match for one or more using the "+" sign. That is pretty much standard grep syntax. And one or more is significant. There are times where zero or more is not precise. The workaround is to specify your pattern twice and follow the second pattern with zero or more, i.e. "*". This has the identical effect to one or more at the expense of code bloat. Issue 2: This is a conceptual difference. Grep is actually a bit of a misnomer for the command. I think REGEX editor is more accurate. Here's why: First grep typically operates line by line returning the entire line (or filename) that matches (this supposedly can be worked around but is not the default). WebDNA will not break at the line end by default. To me this difference is neither good nor bad. Second, grep does not replace anything. It only matches. To make changes, one must edit. At the command line, this is done by tools other than grep. Sed in particular comes to mind. This to me is problematic as a concept. Do not expect grep at the command line to provide a search and replace. Also, if you are learning regex, there are two nice places to experiment. The command line is nice since it is a good way to review multiple files. Try grep and sed for starters. The other place is BBEdit if you have a Mac. It has a nice regex search tool. The power of learning regex is that you can use just about in any programming or web related tool: perl, js, apache (modrewrite in particular), webdna, php, SQL. Bill -----Original Message----- From: Dan Strong Sent: Wed, 21 Sep 2005 10:47:28 -0700 To: "WebDNA Talk" Subject: Re: Grep two things at once? John, thank you. So far I've been able to get away with simple grep stuff, but I guess it's time to get the book ... :) -Dan On Wed, 21 Sep 2005 13:38:59 -0400 John Peacock wrote: > Dan Strong wrote: >> Example: I want to search for any dashes and a spaces in some text and >> replace them with underscores. > > Get the O'Reilly book "Regular Expressions" if you want to do anything significantly useful with >[grep]. This will do what you want: > > [grep search=[- ]&replace=_]the text[/grep] > > The [- ] signifies a set of characters. > > HTH > > John > > -- > John Peacock > Director of Information Research and Technology > Rowman & Littlefield Publishing Group > 4501 Forbes Boulevard > Suite H > Lanham, MD 20706 > 301-459-3366 x.5010 > fax 301-429-5748 > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ devaulw@onebox.com

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebCat2 several catalogs? (1997) Dark Horse Comics success story (1997) HELP WITH DATES (1997) Content search & results (2008) Email notification to one of multiple vendors ? (1997) Keep away (1997) creator code (1997) RE: Any limit to [include] (1997) WebCatalog for Postcards ? (1997) docs for WebCatalog2 (1997) TCPConnect Very Slow (2006) Shopping problems with 2.1b3 acgi (1997) Search design (1997) [include ...] behavior (1997) RE: Adding a product from another site (1997) Install Webcatalog under NT4.0 and Microsoft IIS 2.0 (1997) ShowIF Question (2000) problems with 2 tags shakur (1997) [WebDNA] SMTP via gmail is NOT POSSIBLE (2013) Dates as 20020902 (2002)