Skip to content
Advertisement

If statement filtering with a * character inside the value

I’m iterating a dataframe with the following code:

JavaScript

I’m trying to get values that are only s3:*. However the above code also detects cases such as s3:*Object and s3:*MultipartUpload*.

How do I define the if statement to only get values that contain only s3:*?

Advertisement

Answer

Not sure if I really understand the question, but if you just want to check whether the string is literally 's3:*', i.e. the * is not supposed to be some kind of placeholder/wildcard, just use ==:

JavaScript

If you are looking for 's3:*' (but not 's3:*stuff*') as part of a larger string, e.g. "some string with s3:* inside", then you might use str.split or resort to a regular expression.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement