Which string function can I use to strip everything after - ? The string is not predefined so rtrim() does not work.
9453-abcafaf3ceb895d7b1636ad24c37cb9f-100.png?1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
splitexplodefunction and the “-” character as the delimiter. It will return an array of strings. If you only care about information before the first dash, just use the zeroth index of the returned array.edit:
Sorry. After living in the python world for several months, split was the first thing that came to mind.
explodeis the correct function.edit 2:
strip,lstrip, andrstripare meant to be used for trimming whitespace off the end(s) of a string.