google / google/go-jsonnet

request for function `std.contains`

Open
#381 9 comments 3 reactions 0 assignees View on GitHub
docs stdlib
Dominant language
Go
Stars
1.8k
Forks
263
PR merge metrics
No merged PRs in 30d

Description

This is a request to have a stdlib function for `contains`. Right now, I'm using something like:

```
strContains(s, substr):: (
std.length(std.findSubstr(substr, s)) > 0
)
```

But the problem is that `findSubstr` is doing a regex, so I need to be aware of that and escape, which is not always possible, if that value isn't hard-coded.

*edit* or at least that's how it reads from the documentation:

```
std.findSubstr(pat, str)

Returns an array that contains the indexes of all occurances of pat in str.
```

the use of `pat` being short for `pattern` usually meaning regex.

Is there another way to do this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.