• Login
Community
  • Login

Wildcard in Replace Line?

Scheduled Pinned Locked Moved General Discussion
4 Posts 3 Posters 509 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.
  • X
    x-77-x
    last edited by x-77-x Mar 10, 2024, 6:22 PM Mar 10, 2024, 4:54 PM

    i got…

    \\15,30,5
    P=2123,52,1
    

    and im trying to make

    TIMELO=15
    TIMEHIGH=30
    MAXDIST=5
    P=2123,52,1
    

    and of course all the values are different, 6000 some different instances…

    i tried \\.*,.*,.* & \\\d+,\d+,\d+ in the search line, but not sure how to do the replace…
    also, i dont want to disrupt the commas in the P= line (so i cant just do a global comma replace)

    i could changes that \\ to something else, if its causing a problem

    basically im trying to change
    \\ to TIMELO=
    comma 1 to TIMEHIGH=
    comma 2 to MAXDIST=
    keeping the values
    ONLY on the \\ LINE

    any ideas? thanks

    1 Reply Last reply Reply Quote 1
    • C
      Coises
      last edited by Mar 10, 2024, 6:15 PM

      You want:

      Find what: ^\\\\(\d++),(\d++),(\d++)$
      Replace with: TIMELO=$1\r\nTIMEHIGH=$2\r\nMAXDIST=$3

      The caret (^) indicates the beginning of a line, and the dollar ($) in find indicates the end of a line.

      The backslashes (\) at the beginning of the line are doubled because backslash is an escape character; you need two to represent one.

      The \d indicates a digit; following it with two plus signs (\d++) means as many digits as possible in a row, but at least one.

      The parentheses indicate capture groups, which can be referenced in the replacement using $n where n is the number of the capture group, counting from 1.

      \r\n is a Windows line ending.

      X 1 Reply Last reply Mar 10, 2024, 6:20 PM Reply Quote 2
      • X
        x-77-x @Coises
        last edited by x-77-x Mar 10, 2024, 6:21 PM Mar 10, 2024, 6:20 PM

        AMAZING!!! thank you Coises!

        how do you guys even know this stuff!? =)

        A 1 Reply Last reply Mar 10, 2024, 6:34 PM Reply Quote 0
        • A
          Alan Kilborn @x-77-x
          last edited by Mar 10, 2024, 6:34 PM

          @x-77-x said in Wildcard in Replace Line?:

          how do you guys even know this stuff!?

          Umm, it’s all documented in the User Manual, which is linked to from the ? menu option in Notepad++…

          Look under the Searching heading, for Regular Expressions.

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