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

397Hello (Reg. Exp. Find and Replace, coding question)!

Expand Messages
  • copyacademyperfect
    Apr 13, 2008
    • 0 Attachment
      This is a nOOb warning, going out first. Just so you know; in case the
      question is really dumb - maybe I should explain... I've been coding
      for twelve hours, or so, and It wasn't on purpose. I got stuck with
      this batch rename .txt-file I wanted to make, but I can't solve the
      final detail.

      So I beg all nice ladies (how big is the chance?) and gentlemen...
      please help me out (it's not a matter of life and death, unless lack of
      satisfied curiousity is gonna kill me soon).


      First Line:


      //the file consists of several lines that look somewhat like this, and
      they can be divided into left and right parts. I want to move the right
      part of the line to the left side with text modifications to both parts.

      This is how I coded (one of the versions) the first line's match

      (BLACK_)(.+)(_BMP) BITMAP "Bitmap_(\d{3}|\d{2})(.bmp)"

      //...with the quotes. This code find the various lines in the document
      (havent tested all, but I see no reason why it shouldn't work).

      I changed the second word to "(.+)" because it changes every line. I
      also added "\d{3}" as an alternative since the number (HERE=20) will
      increase above "100" in just eighty lines.

      There's more than one reason why I'm using substring tokens where it's
      not really necessary, which leads me to chat about the "replace field."
      This is how I want the first line replaced://


      //This is how it turned out and how I coded://



      //I am having difficulties with the digit(s) that is/are supposed to
      initiate the second word. Sure I could just: $1\0\0$4$3$5=$1$2$3$5,
      insert them there, but sooner or later the second word will reach above
      100 and then there will be five digits in the second word://



      I have tried everything I've learned during these 18 hours or so, but I
      can not solve it. How do I enforce maximum four digits (add only one
      zero if above 99, instead of two) on the second word?

      The practical solution is so simple. I'd just run the first 80 lines
      adding two digits, and then the rest adding one. But I'd really wanna
      know if there's a way?

      Thanks for reading.
    • Show all 3 messages in this topic