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

Re: [Clip] RegEx Replace

Expand Messages
  • Lee Underwood
    Thanks for the explanation, Axel. I appreciate it! ... and all the others too. Lee
    Message 1 of 14 , Jan 26, 2011
    • 0 Attachment
      Thanks for the explanation, Axel. I appreciate it! ... and all the others too.

      Lee


      > Lee Underwood wrote:
      > > What exactly does the "$" do? Wouldn't
      > >
      > > ^!Replace "<p>" >> "<p> " WRASTI
      > >
      > > work just as good?
      >
      > Not in the case as specified (and in your example you'd have to leave
      > out the R, i.e. WASTI not WRASTI). Graham did not want to replace ALL
      > <p> but only those directly followed by a digit.
      > So I look for "any digit" i.e. \d. This now becomes part of the search
      > term an will get replaced, meaning it will be lost if my replace is only
      > "<p>  ". By placing it in (the first pair of) brackets, Regex will
      > remember it as term number one. So I need to add "term number one" to
      > the replace string, which is exactly what $1 stands for. Which leads us
      > straight back to my formulation
      > ^!Replace "<p>(\d)" >> "<p>  $1" WRASTI
      >
      > As always there are alternatives in Regex. You can say "look for
      > <something> when followed by <soemthing else> and do not make <something
      > else> part of the search term". This can be quite useful and diodem uses
      > it a lot, but I can't remember the details and syntax.
      >
      > A third alternative would be
      > ^!Replace "(<p>)(\d)" >> "<p>  " WRASTI1
      > The two pairs of brackets define term one and term two and the one in
      > WRASTI1 (I hope your font lets you see a capital i followed by a digit
      > 1) says "only replace term one and leave the rest alone".
      >
      > As usual the version I have used is the most primitive one.
      >
      > Axel
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.