Open brackets in a string field

I’m trying to define a string that contains open brackets in a string field -

search_query = “event: "An error occurred during metamodel prediction" AND NOT @timestamp: [* TO "2020-06-23T09:00:00"]”

But I’m getting the next error -

error parsing regexp: invalid character class range: 6-2

Is there something from the user side or from the provider development side to get over it?

Hi @OrNovo,

Unfortunately without more information I don’t think this question is answerable. It’s not clear exactly what is returning that error you’ve described. I’m not sure what additional information to ask for exactly, since I don’t have much to start from here, but at least a summary of what you’re trying to achieve and what you tried so far would be helpful.

With that said, I can say that Terraform doesn’t ascribe any special meaning to brackets in quoted strings, so whatever is returning this message must be in another layer below the main Terraform language implementation.

The “error parsing regexp” prefix seems to suggest that something is trying to parse this string as a regular expression. I would suggest trying to determine what is responsible for that parsing – is it being done by a provider? – and then learning from that system’s documentation how they expect you to pass literal brackets without them being interpreted as a regular expression character class.

I saw now that the string attribute contains validation.StringIsValidRegExp.