tags:

views:

82

answers:

1

Hi, I've got a string looks like this

String a is "ACdA(a = %b, ccc= 2r2)"

String b is "\ewfsd\ss.jpg"

Expected outputs:

ACdA(a = %b, ccc= 2r2, b_holder = \ewfsd\ss.jpg)

It adds the string b to the end of string a, that's it! But be careful of the ")"

"b_holder " is hard coded string, it's absolutly same in all cases, won't be changed.

Thanks everyone!

Update: If regular expression is not a best choice here, please suggest a best way to do.

Thanks everyone!

+1  A: 

Is

a = "ACdA(a = %b, ccc= 2r2)"
b = "\ewfsd\ss.jpg"
print a[:-1] + ', b_holder = ' + b + ')'

what you had in mind?

Most days of the week, I personally prefer

print '%s, b_holder = %s)' % (a[:-1], b)

I recognize I'm likely in the minority in this particular regard.

There certainly are other implementations, some of them RE-based. I favor the ones above, given what the original questioner has expressed.

Cameron Laird
+1 good solution
rubik