Loading ...
Sorry, an error occurred while loading the content.

2994Re: Can we write multiple lines at the same time (with Macros)

Expand Messages
  • tailing_loop2003
    Oct 4, 2004
    • 0 Attachment
      --- In editplus@yahoogroups.com, John Morse <john_morse@s...> wrote:
      > Awesome! Thanks for sharing this with us. Works great for everything
      > that doesn't have a space in-between, how can you change it so that
      if
      > there is a space it will account for it as well?
      > for example:
      > The macro changes this:
      > <META NAME=Author CONTENT=John Morse>
      > To this:
      > <META NAME="Author" CONTENT="John" Morse>
      > When it should be this:
      > <META NAME="Author" CONTENT="John Morse">
      > I'm sure its just needs a slight change to the regular expression
      > string ( [a-z]+=)([a-z0-9#%]+) but i'm not sure what to add to it.
      >

      It's been awhile since I've done any regular expressions, but that
      looks like a pretty simple one.

      ( [a-z]+= )

      [a-z] looks for any lower case character
      [a-z]+ looks for a lower case character 1 or more times
      [a-z]+= looks for a lower case character 1 or more times followed by
      an equals sign.

      The parentheses just delimit that group(which comes into play later
      with the replacement expression).

      For the next part of the regular expression:

      ( [a-z0-9#%]+ )

      [a-z0-9#%] looks for the characters a-z, or 0-9, or #, or %, with the
      plus sign once again meaning one or more times.

      So, putting it all together, the expression looks for:

      the characters a-z one or more times, followed by an equals sign,
      followed by the characters a-z, 0-9, #, or % one or more times.

      Hopefully, that wasn't too confusing. Now it's time to look
      at what
      matches to the regular expression will be replaced by:

      \1"\2"

      If I remember correctly, \1 stands for whatever matches what's in
      the
      first set of parentheses in the regular expression, and \2 stands for
      whatever matches what's in the second set of parentheses in the
      regular expression. Therefore, you can add parentheses to a regular
      expression in order to refer to them later in the replacement
      expression, and the first set of parenthesis will always be \1 and the
      second set will always be \2, and so on. Since the quotes are added
      around \2, whatever matches the second set of parenthesis in the
      regular expression will be enclosed in quotes.

      Now, to answer your question (finally!). All you have to do is add a
      space to the expression in the second set of parenthesis, like this:

      ([a-z0-9#% ]+)

      For image names, like myimage.jpg, in order to put quotes around the
      whole name, for example:

      href="myimage.jpg"

      instead of this(which happens with the current regular expression):

      href="myimage".jpg

      you also need to add a period to the second set of parentheses in the
      regular expression. However, a period has a special meaning in
      regular expressions, so if you literally want to signify a period, you
      have to precede it with a '\':

      ( [a-z0-9#% \.]+ )

      Since, I also use names for my images like:

      my_image.jpg

      I would also add the underscore to the second set of parentheses in
      the regular expression:

      ( [a-z0-9#% \._]+ )




      > Thanks again!!!
      > ~John
      > "Oh Lord, give me patience. But give it to me RIGHT BLOODY NOW!"
      >
      > Friday, October 1, 2004, 12:15:21 PM, you wrote:
      > DH> Another of my favorite macros is one that adds quotes to all
      html tag
      > DH> values that are not quoted. For example, if you had:
      > DH> <table width=580 height=600>
      > DH> It would change it to:
      > DH> <table width="580" height="600">
      > DH> which is XHTML compliant.
      >
      > DH> The Macro to do this is:
      > DH> CTRL+h (Replace dialog)
      > DH> Replace:
      > DH> ( [a-z]+=)([a-z0-9#%]+)
      > DH> With:
      > DH> \1"\2"
    • Show all 14 messages in this topic