SHARE
TWEET

Untitled

a guest Jun 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string = "{part1}_{part2}_{part3}"
  2.      
  3. result = string.format(part1="A", part2="", part3="B")
  4. actual_result = "A__B"
  5. desired_result = "A_B"
  6.      
  7. result = string.format(part1="A__A", part2="", part3="B__B")
  8. result = result.replace("__", "_")
  9. actual_result = "A_A_B_B"
  10. desired_result = "A__A_B__B"
  11.      
  12. ignore_str = "$IGNORE_STRING$"
  13. string = "{part1}_{part2}_{part3}"
  14.  
  15. result = string.format(part1="A__A", part2=ignore_str, part3="B__B")    
  16. result = result.replace("_" + ignore_str, "")
  17. actual_result = "A__A_B__B"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top