Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39944

String::replaceAll method in groovy script works not as described in man.

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • pipeline
    • None

      ...
      def testString = "Multi line"
      def testStringReplaced = ( testString.replaceAll(~/(line)/,

      { it[0] + it[0] }

      ) )
      echo testStringReplaced
      ...

      This block produces output: lineline
      I expect it to produce: Multi lineline

          [JENKINS-39944] String::replaceAll method in groovy script works not as described in man.

          Vladimir Fomenko created issue -
          Vladimir Fomenko made changes -
          Description Original: ...
          def testString = "Multi line"
          def testStringReplaced = ( testString.replaceAll(~/(line)/, { it[0] + it[0] }) )
          echo testStringReplaced
          ...

          This block produce output: lineline
          I expect it to produce: Multi lineline

          New: ...
          def testString = "Multi line"
          def testStringReplaced = ( testString.replaceAll(~/(line)/, { it[0] + it[0] }) )
          echo testStringReplaced
          ...

          This block produces output: lineline
          I expect it to produce: Multi lineline

          Andrew Bayer made changes -
          Link New: This issue duplicates JENKINS-46358 [ JENKINS-46358 ]
          Andrew Bayer made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            fomenko Vladimir Fomenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: