Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  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"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement