Community
    • Login

    Notepad++ help for fast formatting date of births

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 96 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Laura HarrisonL
      Laura Harrison
      last edited by Laura Harrison

      Hi everyone
      i am trying to format date of births with double quotes
      does anyone know a fast formula that can be used eg in Find and replace to add the double quotes quickly?
      eg if i have the dates in format yyyy-mm-dd and I need to have a formula to mass add double quotes to a large volume of data
      If we have a large number of rows of data and each item needs double quotes on it per each line of data
      anyone come across any bulk formulas to achieve that?

      If anyone has any advice please let me know?
      Thank you for anything you can share

      PeterJonesP Laura HarrisonL 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Laura Harrison
        last edited by

        @Laura-Harrison ,

        In regular expressions, \d means “a digit” and {4} means “four of the previous token” (and similar), so FIND = \d{4}-\d{2}-\d{2} finds yyyy-mm-dd. In the replacement, $0 will be replaced by the entire string from the FIND, so REPLACE = "$0" will put quotes around the yyyy-mm-dd string.

        You, of course, need to set Search Mode = Regular expression in order for it to use regular expressions.

        ----

        Useful References

        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        Laura HarrisonL 1 Reply Last reply Reply Quote 3
        • Laura HarrisonL
          Laura Harrison @Laura Harrison
          last edited by

          @Laura-Harrison

          @PeterJones said in Notepad++ help for fast formatting date of births:

          \d{4}-\d{2}-\d{2}

          thanks for your advice
          i have to remove these unwanted " marks like in example below before the formula
          199"0-"0"8-"28

          is there a way to add something to the formula you mention above to overcome this?
          thanks

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • Laura HarrisonL
            Laura Harrison @PeterJones
            last edited by

            @PeterJones
            can you give us a formula when you have to remove quote marks from date births
            before adding quote marks at each end of the date of birth
            when it is format
            yyyy-mm-dd

            example I have the date of birth eg 199"2-"1"1-"12
            and just want the double quote marks either side

            1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Laura Harrison
              last edited by

              @Laura-Harrison ,

              Don’t post essentially the same thing twice. The posting form reminds you that until you have enough upvotes, you have to wait for the posting queue for the post to show up.

              If all of your badly-quoted dates have the quotes in exactly the same places (3 digits, quote, digit, hyphen, quote, digit, quote, digit, hyphen, quote, two digits), then you can use a similar idea to above, but put each into capture groups using the (...) notation: FIND = (\d{3})"(\d)-"(\d)"(\d)-"(\d{2}) . Each capture group gets numbered 1-5 for each set of parens, and is $1 - $5 in the REPLACE WITH field. So REPLACE WITH = "$1$2-$3$4-$5"
              This will take

              199"0-"0"8-"28
              199"2-"1"1-"12
              

              and make it

              "1990-08-28"
              "1992-11-12"
              

              But I have a feeling you are going to tell me in the next post that what you really have is quotes in different places each time, like

              1"99"0-"0"8-"28
              199"2-"1"1-"12
              "2"0"2"6"0"1"0"6"
              

              In which case, I’d say, look for “possible quote, digit, possible quote, digit, possible quote, …etc”, where “possible quote” is in regex as "? (which means "0 or 1 quote mark)
              FIND = "?(\d)"?(\d)"?(\d)"?(\d)"?-"?(\d)"?(\d)"?-"?(\d)"?(\d)"?
              REPLACE = "$1$2$3$4-$5$6-$7$8"
              REPLACE ALL
              would give

              "1990-08-28"
              "1992-11-12"
              "2026-01-06"
              

              (Note that if you had more digits than that, like if you also had hh:mm:ss, so it would be up to 14, the replacements for 10-14 would be ${10} - ${14})

              1 Reply Last reply Reply Quote 3
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors