2

What I'm trying to do is just concatenate arguments to my existing string "./executable.sh", so that output row set would look like that

./executable.sh argument1
./executable.sh argument3
./executable.sh argument2
  ...
  ...

Below is the "Replacement in string" step. Search is set to (.*) . Replacement field is set to ./executable.sh $1

Replace in string step

Results that I'm getting are:

./executable.sh argument1./executable.sh 
./executable.sh argument2./executable.sh 
./executable.sh argument3./executable.sh 

How come I'm getting the initial string added to the end of the replacement ?

Thank you.

ilya_i
  • 333
  • 5
  • 14

1 Answers1

1

The problem here is that your regex can match a null/empty string that is matched after the string (i.e. the engine behind the scenes splits the string into two parts: all the characters and the terminating null string, and thus you get two matches that are replaced).

To avoid that, you need to use either

(.+)

or

^(.*)$

The (.+) pattern matches 1 or more characters other than a newline, and ^(.*)$ matches 0 or more characters other than a newline from the start of the string (^) to the end of it ($). Explicit anchors in the second pattern help get rid of matching the null string at the end of the input.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563